Skip to content

Accept managed OAuth tokens that carry earlier consent - #333

Merged
tnkuehne merged 1 commit into
mainfrom
managed-oauth-accumulated-consent
Nov 23, 2026
Merged

tnkuehne merged 1 commit into
mainfrom
managed-oauth-accumulated-consent

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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 with OAuth 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:

  • New connections failed with invalid_code.
  • Running connections failed at their next refresh.

What changes

  • Token responses (packages/app-runtime/src/oauth.ts): the broker no longer rejects or revokes a token whose granted scopes go beyond the client's scopes. The granted scopes are still returned to the app as before.
  • Authorization requests are unchanged. The broker still refuses requested scopes and provider default scopes outside the client's 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:
    • Requests outside the allowed scopes are still refused.
    • A wider grant is accepted without a revocation.
    • The test client no longer lists Google's long userinfo.* names, so every exchange and refresh in the suite now returns scopes outside the client's list.
  • oauth.test.ts and template-oauth.test.ts pass (48 tests). Typecheck, format and lint are clean for the changed files.

RetriggerView in GreptileConfidence 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.

  • The OAuth broker accepts provider tokens with scopes beyond its configured list.

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

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.
@tnkuehne
tnkuehne merged commit 1a4bdab into main Nov 23, 2026
15 checks passed
@tnkuehne
tnkuehne deleted the managed-oauth-accumulated-consent branch November 23, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant