Repository navigation
[v1.x] fix(client): start a new authorization when the step-up needs a scope that the token lacks - #3114
Open
nicolas-grekas wants to merge 2 commits into
Conversation
…a scope that the token lacks A refresh cannot add scopes, so the retry of a 403 insufficient_scope got the same 403 when the client had a refresh token. The new authorization also asks for the scopes requested and granted before. Same change as modelcontextprotocol#2356 on main. Fixes modelcontextprotocol#2255.
🦋 Changeset detectedLatest commit: 5240f3b The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
The 403-scope-upgrade scenario now gives its refreshed token the challenged scope, so that it still covers the refresh and the loop guard.
This branch has not been deployed
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.
Backport of the step-up part of #2356 to
v1.x. Fixes #2255.On a
403 insufficient_scope,auth()refreshes the token when the provider has a refresh token. A refresh cannot add scopes (RFC 6749 §6), so the retry gets the same 403 and the transport throws "Server returned 403 after trying upscoping". The user is never asked for the missing scope.Now the transport passes
forceReauthorizationtoauth()when the token lacks a challenged scope.auth()then starts a new authorization instead of refreshing. Like onmain, this authorization also asks for the scopes requested and granted before, so the new token keeps them (#1582 forv1.x). I left out the retry cap of #2356, and kept the existing guard against a repeated challenge.The redirects test and the
403-scope-upgradee2e scenario now give the token the challenged scope, so that they still cover a refresh. The e2e suite also gets thestepup:scope-unionandstepup:refresh-bypass-on-supersetscenarios ofmain.I found this while building an MCP server for the Symfony showcase app, with Keycloak as authorization server. With 1.32.2, the step-up refreshes the token and fails. With this branch, it asks for
openid profile email proposals:writeand the call succeeds.