woodpecker-ci / woodpecker

Woodpecker is a simple, yet powerful CI/CD engine with great extensibility.
https://woodpecker-ci.org
Apache License 2.0
4.07k stars 353 forks source link

Gitea login endless loop #1148

Closed H4CK3R-01 closed 2 years ago

H4CK3R-01 commented 2 years ago

Component

server, web-ui

Describe the bug

If I try to login into gitea I get redirected to my gitea instance at the first time. There I can authorise woodpecker and then I get redirected back to my woodpecker instance. But again to the login view (/do-login). The next time I try to login the page refreshes only but nothing happens

Another server with the same config but connected to github is working fine.

System Info

{"source":"https://github.com/woodpecker-ci/woodpecker","version":"0.15.3"}

I'm using docker-compose.

Additional context

No response

Validations

6543 commented 2 years ago

is it possible for you to test against next tag?

H4CK3R-01 commented 2 years ago

Yes. Unfortunately the same mistake.

{"source":"https://github.com/woodpecker-ci/woodpecker","version":"next-c79d49c8"}
H4CK3R-01 commented 2 years ago

Maybe you have a working docker-compose config for gitea and woodpecker?

6543 commented 2 years ago

https://woodpecker-ci.org/docs/next/administration/setup#docker-compose and https://woodpecker-ci.org/docs/next/administration/forges/gitea I would say?

H4CK3R-01 commented 2 years ago

This is exactly the documentation I used. But this does not work :-(

6543 commented 2 years ago

just to make sure can you post the full config (secrets redacted)?

H4CK3R-01 commented 2 years ago

My docker-compose.yml-file

version: '3'

services:
  woodpecker-server:
    image: woodpeckerci/woodpecker-server:next
    restart: unless-stopped
    volumes:
      - woodpecker_server_data:/var/lib/woodpecker/
      - /etc/localtime:/etc/localtime
      - /etc/timezone:/etc/timezone
    environment:
      - WOODPECKER_LOG_LEVEL=${WOODPECKER_LOG_LEVEL}
      - WOODPECKER_DEBUG_PRETTY=${WOODPECKER_DEBUG_PRETTY}
      - WOODPECKER_DEBUG_NOCOLOR=${WOODPECKER_DEBUG_NOCOLOR}
      - WOODPECKER_ADMIN=${WOODPECKER_ADMIN}
      - WOODPECKER_ORGS=${WOODPECKER_ORGS}
      - WOODPECKER_OPEN=${WOODPECKER_OPEN}
      - WOODPECKER_GITEA=${WOODPECKER_GITEA}
      - WOODPECKER_GITEA_URL=${WOODPECKER_GITEA_URL}
      - WOODPECKER_GITEA_CLIENT=${WOODPECKER_GITEA_CLIENT}
      - WOODPECKER_GITEA_SECRET=${WOODPECKER_GITEA_SECRET}
      - WOODPECKER_HOST=${WOODPECKER_HOST}
      - WOODPECKER_AGENT_SECRET=${WOODPECKER_AGENT_SECRET}
      - WOODPECKER_DATABASE_DRIVER=mysql
      - WOODPECKER_DATABASE_DATASOURCE=${DATABASE_USER}:${DATABASE_PASSWORD}@tcp(${DATABASE_HOST}:3306)/${DATABASE_DB}?parseTime=true
      - WOODPECKER_PROMETHEUS_AUTH_TOKEN=${WOODPECKER_PROMETHEUS_AUTH_TOKEN}
    networks:
      default:
        ipv4_address: ${IP_SERVER}

  woodpecker-agent:
    image: woodpeckerci/woodpecker-agent:latest
    restart: unless-stopped
    depends_on:
      - woodpecker-server
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /etc/localtime:/etc/localtime
      - /etc/timezone:/etc/timezone
    environment:
      - WOODPECKER_SERVER=${IP_SERVER}:9000
      - WOODPECKER_AGENT_SECRET=${WOODPECKER_AGENT_SECRET}
    networks:
      default:
        ipv4_address: ${IP_AGENT}

networks:
  default:
    external:
      name: ens18_net

volumes:
  woodpecker_server_data:

And the .env-file

IP_SERVER=10.0.1.156
IP_AGENT=10.0.1.157

WOODPECKER_LOG_LEVEL=debug
WOODPECKER_DEBUG_PRETTY=true
WOODPECKER_DEBUG_NOCOLOR=false
WOODPECKER_ADMIN=H4CK3R-01
WOODPECKER_ORGS=
WOODPECKER_OPEN=true
WOODPECKER_GITEA=true
WOODPECKER_GITEA_URL=https://git.<domain>.com
WOODPECKER_GITEA_CLIENT=<client-id>
WOODPECKER_GITEA_SECRET=<client-secret>
WOODPECKER_HOST=https://gitea.woodpecker.<domain>.com
WOODPECKER_AGENT_SECRET=<agent-secret>

DATABASE_USER=woodpecker
DATABASE_PASSWORD=<password>
DATABASE_HOST=mariadb
DATABASE_DB=woodpecker_gitea
WOODPECKER_PROMETHEUS_AUTH_TOKEN=
6543 commented 2 years ago

hmm port export at woodpecker-server is missing, how did you export this?

H4CK3R-01 commented 2 years ago

I use my nginx reverse proxy (Nginx-Proxy-Manager) for that.

I have two instances of woodpecker on my server. \ One is connected to github, the other one to gitea. They have almost the same config as posted before. Only the Gitea/Github specific options and ip addresses are different. The port export is missing in both configs. The github woodpecker is working, the gitea woodpecker not.

6543 commented 2 years ago

hmm I guess the Redirect URI at gitea is wrong

make sure it's: https://gitea.woodpecker.<domain>.com/authorize

H4CK3R-01 commented 2 years ago

It's exactly this url (of course <domain> is replaced with the right domain :-))

H4CK3R-01 commented 2 years ago

I don't know if some logs will help to solve this. These are the logs if I click on the login-button:

5:41PM DBG woodpecker/src/github.com/woodpecker-ci/woodpecker/server/api/stream.go:77 > user feed: connection closed
5:41PM INF woodpecker/src/github.com/woodpecker-ci/woodpecker/server/router/middleware/logger.go:45 > ip=<ip> latency=533148.261551 method=GET path=/stream/events status=200 user-agent="Mozilla/5.0 (X11; Linux x86_64; rv:104.0) Gecko/20100101 Firefox/104.0"
5:41PM INF woodpecker/src/github.com/woodpecker-ci/woodpecker/server/router/middleware/logger.go:45 > ip=<ip> latency=0.510307 method=GET path=/login status=303 user-agent="Mozilla/5.0 (X11; Linux x86_64; rv:104.0) Gecko/20100101 Firefox/104.0"
5:41PM INF woodpecker/src/github.com/woodpecker-ci/woodpecker/server/router/middleware/logger.go:45 > ip=<ip> latency=0.460073 method=GET path=/authorize status=303 user-agent="Mozilla/5.0 (X11; Linux x86_64; rv:104.0) Gecko/20100101 Firefox/104.0"
5:41PM INF woodpecker/src/github.com/woodpecker-ci/woodpecker/server/router/middleware/logger.go:45 > ip=<ip> latency=93.736901 method=GET path=/authorize status=303 user-agent="Mozilla/5.0 (X11; Linux x86_64; rv:104.0) Gecko/20100101 Firefox/104.0"
5:41PM DBG woodpecker/src/github.com/woodpecker-ci/woodpecker/server/api/stream.go:58 > user feed: connection opened
6543 commented 2 years ago

@H4CK3R-01 if you can dm me your instance via matrix/discord so I can give it a try?

H4CK3R-01 commented 2 years ago

Sure, can you tell me your discord username?

6543 commented 2 years ago

6543#1089 as usual, on you discord server ... https://discord.gg/fcMQqSMXJy as per readme

6543 commented 2 years ago

-> nginx did cache /web-config.js so after successfull auth it could not get CSRF and USER