Skip to content

Conversation

@Oliver-Hanikel
Copy link

@Oliver-Hanikel Oliver-Hanikel commented Aug 16, 2022

Description

I copied providers/github.go and providers/github_test.go to make providers/gitea.go and gitea_test.go.
gitea_test.go is still unchanged.
The Gitea Provider now takes /api/v1/user as ValidateURL. The Base URL for making API requests gets created by taking the dir of the supplied URL.

Motivation and Context

This change fixes #1636 by taking /api/v1/user as ValidateURL instead of /api/v1, because Gitea returns 404 for /api/v1.
There is a lot of cruft still hanging around in providers/gitea.go. I don't know what is needed and what is not. I also haven't fixed all comments in providers/gitea.go.
providers/gitea_test.go still has to be changed so go test works again.
I got time the next few weeks so I am willing to finish the Gitea provider, if you give me some directions.
Also this is my first time programming in Golang, so feel free to criticize me.

How Has This Been Tested?

I built the docker image and tested the login workflow with the following docker-compose.

docker buildx build --platform linux/amd64 -t test/oauth2-proxy .
version: '3'
services:
  whoami:
    image: containous/whoami
    container_name: whoami
    restart: unless-stopped
    ports:
      - 80:80
  oauth-proxy:
    image: test/oauth2-proxy
    container_name: oauth-proxy
    ports:
      - 8000:8000
    environment:
      - OAUTH2_PROXY_HTTP_ADDRESS=0.0.0.0:8000
      - OAUTH2_PROXY_REVERSE_PROXY=false
      - OAUTH2_PROXY_EMAIL_DOMAINS=*
      - OAUTH2_PROXY_REDIRECT_URL=http://127.0.0.1:8000/oauth2/callback
      - OAUTH2_PROXY_UPSTREAMS=http://whoami:80
      - OAUTH2_PROXY_PROVIDER=gitea
      - OAUTH2_PROXY_PROVIDER_DISPLAY_NAME=Gitea
      - OAUTH2_PROXY_LOGIN_URL=https://<my-gitea>/login/oauth/authorize
      - OAUTH2_PROXY_REDEEM_URL=https://<my-gitea>/login/oauth/access_token
      - OAUTH2_PROXY_VALIDATE_URL=https://<my-gitea>/api/v1/user
      - OAUTH2_PROXY_CLIENT_ID=ef2706de-b611-449c-a88c-037cbd9a27b1
      - OAUTH2_PROXY_CLIENT_SECRET=UtEiM02491GQtgbUmV27XFUCujNCzMdTX9eO2Ur9m2LE
      - OAUTH2_PROXY_COOKIE_SECRET=1m0NiLTieZBo_yNjf6Zcv8XJ0jDey-4Jl_4rmPydlGI=
      - OAUTH2_PROXY_COOKIE_SECURE=false
    restart: unless-stopped

Checklist:

  • My change requires a change to the documentation or CHANGELOG.
  • I have updated the documentation/CHANGELOG accordingly.
  • I have created a feature (non-master) branch for my PR.

@Oliver-Hanikel Oliver-Hanikel requested a review from a team as a code owner August 16, 2022 13:33
@Oliver-Hanikel
Copy link
Author

Oliver-Hanikel commented Aug 16, 2022

Ok now the tests are working and there is no more cruft hanging around. I think all that needs to be done is:

  • adding command line options for the allowed gitea org/team/users similar to github
  • update the documentation and changelog
  • testing the allowed org/team/users feature
    • with pagination

@Oliver-Hanikel
Copy link
Author

As far as I'm concerned the code is done and was tested with most possible combinations of gitea parameters being set and unset.

My updated docker-compose used to test:

version: '3'
services:
  whoami:
    image: traefik/whoami
    container_name: whoami
    restart: unless-stopped
    ports:
      - 80:80

  gitea:
    image: gitea/gitea
    container_name: gitea
    ports:
      - 3000:3000
      - 2222:22/tcp
    volumes:
      - ./gitea:/data
    restart: unless-stopped

  oauth-proxy:
    image: test/oauth2-proxy
    container_name: oauth-proxy
    ports:
      - 8000:8000
    environment:
      - OAUTH2_PROXY_HTTP_ADDRESS=0.0.0.0:8000
      - OAUTH2_PROXY_REVERSE_PROXY=false
      - OAUTH2_PROXY_EMAIL_DOMAINS=*
      - OAUTH2_PROXY_COOKIE_EXPIRE=0h0m5s
      - OAUTH2_PROXY_REDIRECT_URL=http://localhost:8000/oauth2/callback
      - OAUTH2_PROXY_UPSTREAMS=http://whoami:80
      - OAUTH2_PROXY_PROVIDER=gitea
      - OAUTH2_PROXY_PROVIDER_DISPLAY_NAME=Gitea
      - OAUTH2_PROXY_LOGIN_URL=http://localhost:3000/login/oauth/authorize
      # Has to use docker network instead of localhost
      - OAUTH2_PROXY_REDEEM_URL=http://gitea:3000/login/oauth/access_token
      - OAUTH2_PROXY_VALIDATE_URL=http://gitea:3000/api/v1/user
      - OAUTH2_PROXY_CLIENT_ID=ded3e589-4c0d-44f2-86da-894086394c0e
      - OAUTH2_PROXY_CLIENT_SECRET=gto_wb4ki7w6vo4fwsmdcavwlbsqjfi6ntsmpl5zpfouh365om3uweuq
      - OAUTH2_PROXY_COOKIE_SECRET=1m0NiLTieZBo_yNjf6Zcv8XJ0jDey-4Jl_4rmPydlGI=
      - OAUTH2_PROXY_COOKIE_SECURE=false

      - OAUTH2_PROXY_GITEA_USERS=898,899,900,901,902,903,904,905 # These are usernames not ids
      # - OAUTH2_PROXY_GITEA_ORG=privateorg
      # - OAUTH2_PROXY_GITEA_TEAM=teamA
      - OAUTH2_PROXY_GITEA_REPO=publicorg/publicrepo
    restart: unless-stopped

@Oliver-Hanikel
Copy link
Author

The only thing missing, as far as I can tell, is changes to the alpha config

@Oliver-Hanikel
Copy link
Author

Is there anything I can do to get this merged?

@JoelSpeed
Copy link
Member

I am reluctant to accept new providers at the moment for several reasons:

  • We are planning a massive rewrite of how the providers are actually implemented
  • We have a large number of providers for lesser known sites that have been abandoned by the implementors
  • Maintainers cannot maintain implementations without access to the systems, which we don't have for most cases
  • Given the scope of this project already, adding new providers wouldn't be sensible right now.

Once we have the new provider implementations in place and we get things a little more sorted, I may revisit this decision, but for now, please maintain this on your own fork

@Oliver-Hanikel
Copy link
Author

Thanks for the response. I hope the rewrite goes well and Gitea will get supported in the future. It would be great for the selfhosted community.

@JoelSpeed
Copy link
Member

Thanks for the response. I hope the rewrite goes well and Gitea will get supported in the future. It would be great for the selfhosted community.

I'd love to be able to support it in the future yes, but right now we can't commit to supporting new providers when the existing collection isn't sustainable for us. I've finished my travels and just about settled post moving house now so hoping to get back into the project a bit more this year

@github-actions
Copy link
Contributor

github-actions bot commented Apr 4, 2023

This pull request has been inactive for 60 days. If the pull request is still relevant please comment to re-activate the pull request. If no action is taken within 7 days, the pull request will be marked closed.

@github-actions github-actions bot added the Stale label Apr 4, 2023
@github-actions github-actions bot closed this Apr 11, 2023
@bendlas
Copy link

bendlas commented Apr 11, 2023

I'm interested in this.

@JoelSpeed said

  • We are planning a massive rewrite of how the providers are actually implemented
  • We have a large number of providers for lesser known sites that have been abandoned by the implementors

I'd argue that Gitea is more than just a lesser-known site: For self-hosting, it's one of the main competitors to Gitlab CE, and there is a number of Gitea cloud providers; e.g. Codeberg

Similar to Gitlab, Gitea can provide easy user and auth management for applications.

Other than Gitlab, it's light on memory and there is a fully libre option (Forgejo).

Please consider re-opening this, or at least adding the hot-fix #1996

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gitea auth provider fails with 7.2.1

3 participants