fix(oidc): pass OIDC_SCOPES as a list of scopes instead of a single string - #2813
Open
chrisblech wants to merge 1 commit into
Open
chrisblech wants to merge 1 commit into
chrisblech wants to merge 1 commit into
Conversation
chrisblech
requested review from
acasajus,
cquintana92 and
nguyenkims
as code owners
September 16, 2026 22:15
acasajus
approved these changes
Sep 17, 2026
acasajus
approved these changes
Sep 17, 2026
acasajus
enabled auto-merge (rebase)
September 17, 2026 14:13
acasajus
force-pushed
the
fix_oidc_scopes
branch
from
September 17, 2026 14:13
78205e9 to
4b95b57
Compare
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.
Fixes #2812
OIDC_SCOPESwas passed toOAuth2Sessionwrapped in a single-element list(
scope=[OIDC_SCOPES]). oauthlib'sscope_to_listdoes not split list elements,so the requested scope set ended up as
{"openid email profile"}— one elementcontaining spaces — while the provider's token response parses to
{"openid", "email", "profile"}. The two sets can never be equal, sovalidate_token_parametersraises and the callback returns a 500.This affects every provider that includes
scopein the token response(Authentik does so unconditionally; RFC 6749 §3.3 makes it optional when the
granted scope matches the request, which is why it goes unnoticed elsewhere).
The value documented in
example.envis affected as well.Changes
app/auth/views/oidc.py: passOIDC_SCOPESdirectly at both call sites.app/config.py: parseOIDC_SCOPESinto a list and add a default ofopenid email profile. Previously an unset variable producedscope=[None],which oauthlib serialises to the literal string
"None". The default matchesexample.envand covers theOIDC_NAME_FIELDdefault ofname, which needsthe
profilescope.OIDC_SCOPEShas exactly three references in the codebase, all touched here, andno test refers to it, so the type change from
strtolist[str]is contained.Testing
Verified against Authentik with
OIDC_SCOPESunset and withOIDC_SCOPES=openid email profile; both complete the login. Confirmed withOAUTHLIB_RELAX_TOKEN_SCOPEremoved from the environment, so the scope check isactually exercised.
tests/auth/test_oidc.pypasses.Not included
Two adjacent problems in the same file are deliberately left out to keep this
reviewable, and can follow as separate issues:
create_user()passesname=oidc_user_data.get(OIDC_NAME_FIELD), which raisesTypeErroronname[:100]when the claim is absent.email_verifiedbefore matching theemailclaimagainst an existing account.