feat(auth): add OIDC/Gitea userinfo support for OAuth2 login#727
Open
achille wants to merge 1 commit intokubero-dev:mainfrom
Open
feat(auth): add OIDC/Gitea userinfo support for OAuth2 login#727achille wants to merge 1 commit intokubero-dev:mainfrom
achille wants to merge 1 commit intokubero-dev:mainfrom
Conversation
The passport-oauth2 strategy doesn't fetch user profile data by default, which breaks authentication with OIDC providers like Gitea that don't embed user info in the access token. Changes: - Override userProfile on strategy instance when OAUTH2_CLIENT_USERINFO_URL is set - Map OIDC standard claims (sub, preferred_username, email, picture) to passport profile - Support Gitea API fields (login, full_name, avatar_url) as fallbacks - Use stable identifiers for username (never display name) to prevent collisions - Add UserProfile interface for type safety - Throw clear error on missing required config instead of silent early return - Replace disabled test file with comprehensive working tests Username mapping priority: preferred_username > login > email > sub/id See: https://docs.gitea.com/development/oauth2-provider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The passport-oauth2 strategy doesn't fetch user profile data by default, which breaks authentication with OIDC providers like Gitea that don't embed user info in the access token.
this pr is written via ai (claude+gemini) and manually verified
Changes:
See: https://docs.gitea.com/development/oauth2-provider
Description
Support for login via gitea/forgejo OIDC.
Type of change
How Has This Been Tested?
ai assisted unit tests (multiple rounds) + manual review
depoyed and tested locally on my homlab
I've built the image and tested it on a kubernetes cluster
Test Configuration:
Checklist: