Repository navigation
Accept managed OAuth tokens that carry earlier consent - #333
Merged
Merged
Conversation
Microsoft puts every scope a user ever consented to for a client into new tokens. When a scope left a managed client's allowed scopes, the broker rejected every exchange and refresh for users who had consented to it, although only the user or an administrator can withdraw that consent. Authorization requests stay limited to the allowed scopes.
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.
Why
Microsoft includes every scope a user has ever consented to for a client in new tokens, not only the scopes in the current request. When a scope is removed from a managed client's
scopes, users who consented to it earlier keep that consent at Microsoft. The broker then rejected every code exchange and every refresh for them withOAuth provider granted scopes this client does not allow.Rejecting the token did not withdraw anything. Only the user or a tenant administrator can remove a consent, so the check locked these users out:
invalid_code.What changes
packages/app-runtime/src/oauth.ts): the broker no longer rejects or revokes a token whose granted scopes go beyond the client'sscopes. The granted scopes are still returned to the app as before.scopes. New consent given through the broker therefore stays within the allowed scopes.To actually take a scope back from existing grants, operators need a new provider registration, which starts without earlier consents.
Tests
packages/app-runtime/src/oauth.test.ts:userinfo.*names, so every exchange and refresh in the suite now returns scopes outside the client's list.oauth.test.tsandtemplate-oauth.test.tspass (48 tests). Typecheck, format and lint are clean for the changed files.

Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
The broker now accepts provider tokens that include earlier consent beyond the client's configured scopes.
Review checks used source inspection. Tests were not run during this review.
Reviews (1) · Last reviewed commit: "Accept managed OAuth tokens that carry e..." · Reviewed by Greptile