Align authserver DCR client scopes with discovery scopes_supported#3610
Open
Align authserver DCR client scopes with discovery scopes_supported#3610
Conversation
DCR was assigning hardcoded DefaultScopes ["openid", "profile", "email"]
to registered clients, while the discovery document advertised whatever
was configured in oidcConfig.inline.scopes. When those differed, clients
would read scopes_supported from discovery, request those scopes, and
get rejected by fosite because the client wasn't allowed them.
For example, with this MCPServer config:
```
oidcConfig:
inline:
scopes: [user:email, read:user, repo]
```
the discovery document would advertise scopes_supported: ["user:email",
"read:user", "repo"], but a DCR client would only be allowed ["openid",
"profile", "email"]. Requesting "user:email" would fail with
invalid_scope.
The fix: DCR now reads h.config.ScopesSupported so clients are allowed
to request exactly the scopes the server advertises. The config default
for ScopesSupported references registration.DefaultScopes directly,
giving a single source of truth instead of two arrays to keep in sync.
Contributor
Author
|
@tgrunnagle I saw one of your manifests using explicit scopes in the oidcConfig.inline.scopes attribute and realized (by testing and running into a bug) that we don't handle the situation well, all my testing was using implicit scopes for the auth server. This fixes the bug. Although in most cases explicit scopes should not be needed, the upstream scopes are configured separately using |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3610 +/- ##
==========================================
- Coverage 65.61% 65.54% -0.07%
==========================================
Files 407 407
Lines 40246 40247 +1
==========================================
- Hits 26407 26381 -26
- Misses 11779 11806 +27
Partials 2060 2060 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
DCR was assigning hardcoded DefaultScopes ["openid", "profile", "email"] to registered clients, while the discovery document advertised whatever was configured in oidcConfig.inline.scopes. When those differed, clients would read scopes_supported from discovery, request those scopes, and get rejected by fosite because the client wasn't allowed them.
For example, with this MCPServer config:
the discovery document would advertise scopes_supported: ["user:email", "read:user", "repo"], but a DCR client would only be allowed ["openid", "profile", "email"]. Requesting "user:email" would fail with invalid_scope.
The fix: DCR now reads h.config.ScopesSupported so clients are allowed to request exactly the scopes the server advertises. The config default for ScopesSupported references registration.DefaultScopes directly, giving a single source of truth instead of two arrays to keep in sync.