woodpecker-ci / woodpecker

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

oauth callback raise an error while use gitea with woodpecker #609

Closed zxcvbnm3057 closed 2 years ago

zxcvbnm3057 commented 2 years ago

Component

server

Describe the bug

see also https://github.com/go-gitea/gitea/issues/17969

Even the woodpeckerci/woodpecker-server:latest raise this error, too.

System Info

{"source":"https://github.com/woodpecker-ci/woodpecker","version":"next-9e8d1a92"}

Additional context

No response

Validations

6543 commented 2 years ago

from https://github.com/woodpecker-ci/woodpecker/issues/605#issuecomment-992854121

new error:

time="2021-12-13T20:15:27Z" level=error msg="cannot authenticate user. oauth2: cannot fetch token: 405 Method Not Allowed\nResponse: "

It happened when I confirm the oauth request in gitea

There is also an error report in Gitea log

Completed GET /login/oauth/access_token 405 Method Not Allowed in 204.447µs
6543 commented 2 years ago

@zxcvbnm3057 can you paste your woodpecker server config?

(replace passwds with xxxxx or so)

zxcvbnm3057 commented 2 years ago
version: "3"

services:
  woodpecker-server:
    image: woodpeckerci/woodpecker-server:latest
    container_name: woodpecker-server
    volumes:
      - /root/woodpecker:/var/lib/woodpecker/
    networks:
      - web-bridge
    restart: always
    environment:
      # This is for nginx-proxy
      - VIRTUAL_HOST=drone.example.com
      - VIRTUAL_PORT=8000

      - WOODPECKER_OPEN=true
      - WOODPECKER_HOST=https://drone.example.com
      - WOODPECKER_GITEA=true
      - WOODPECKER_GITEA_URL=http://code.example.com
      - WOODPECKER_GITEA_CLIENT=xxxxxxxxxxxxx
      - WOODPECKER_GITEA_SECRET=xxxxxxxxxxxxxxx
      - WOODPECKER_AGENT_SECRET="xxxxxxxxxxx"
      # - WOODPECKER_GITEA_PRIVATE_MODE=true
      - WOODPECKER_ADMIN=Admin
6543 commented 2 years ago

@zxcvbnm3057 what do you mean with nginx-proxy that there is no nginx in woodpeckerci/woodpecker-server

zxcvbnm3057 commented 2 years ago

well, that was a plugin for nginx.

PS:The bugs I got this week even more than during the whole past year....

6543 commented 2 years ago

the config seems right - can you test with a secound account to log-in?

zxcvbnm3057 commented 2 years ago

No, but I had reset the oauth token and clean the woodpecker-server data folder many times. But still got nothing.

zxcvbnm3057 commented 2 years ago

So this works fine in your test environment?

6543 commented 2 years ago
# docker-compose.yml
version: '3'

services:
  woodpecker-server:
    image: woodpeckerci/woodpecker-server:latest-alpine
    networks:
      - intern
    ports:
      - 8000:8000
    volumes:
      - ./data/woodpecker:/var/lib/woodpecker/
    environment:
      - WOODPECKER_OPEN=true
      - WOODPECKER_HOST=http://woodpecker-server:8000
      - WOODPECKER_GITEA=true
      - WOODPECKER_GITEA_URL=http://gitea-server:3000
      - WOODPECKER_GITEA_CLIENT=0a40a3d2-adf3-4b27-9d30-64c6a10b94fd
      - WOODPECKER_GITEA_SECRET=gf5XKtr8tlrlUZlnsRgww3i8cvGVokkoIJ4KVKAC1KG4
      - WOODPECKER_AGENT_SECRET=1234512345123451234512345

  woodpecker-agent:
    image: woodpeckerci/woodpecker-agent:latest-alpine
    command: agent
    restart: always
    networks:
      - intern
    depends_on:
      - woodpecker-server
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - WOODPECKER_SERVER=woodpecker-server:9000
      - WOODPECKER_AGENT_SECRET=1234512345123451234512345

  gitea-server:
    image: gitea/gitea:dev
    environment:
      - USER_UID=1000
      - USER_GID=1000
    restart: always
    networks:
      - intern
    volumes:
      - ./data/gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "3000:3000"
      - "2222:22"

networks:
  intern:
    driver: bridge

that one works
PS: tested latest & latest-alpine

zxcvbnm3057 commented 2 years ago

OK, I'll give it a shoot...

zxcvbnm3057 commented 2 years ago

I try to shutdown the nginx and export ports directly, then the problem is solved. It looks like nginx changed the method as the same time do redirect.

zxcvbnm3057 commented 2 years ago

Thank you for all of your help!! That really help me a lot!

one more little thing, I can't downgrade my gitea from dev to latest.....But at least there is no more errors, for now.

6543 commented 2 years ago

@zxcvbnm3057 downgrading gitea is ... a bad idear - if you have no backup, you dont have to worry - gitea is on the way to deliver a new release soon too - so if released just switch there back to latest :)

zxcvbnm3057 commented 2 years ago

haha yeah, I don't worry about it actually. Thank you once again and then I will close this issus. So see you later XD.

A HUGE WAVE OF BUGS IS APPROACHING!