fix(auth): merge configured and server-required OAuth scopes - #1102
Draft
tsarlandie-oai wants to merge 1 commit into
Draft
fix(auth): merge configured and server-required OAuth scopes#1102tsarlandie-oai wants to merge 1 commit into
tsarlandie-oai wants to merge 1 commit into
Conversation
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.
Motivation and Context
Reactive OAuth discovery records scopes required by the server's
WWW-Authenticatechallenge and validated protected-resource metadata. However,AuthorizationSession::newbypasses the existing scope-selection policy wheneverAuthorizationRequest::with_scopessupplies explicit client scopes:As a result, a client configured with
configured shareddoes not requestchallengeorresourcewhen the Bearer challenge and protected-resourcemetadata require them. Duplicate configured scopes are also preserved, and
authorization can fail even though the SDK discovered the scopes necessary for
the operation.
What changed
deduplicating scope-selection policy.
previously requested scopes, Bearer challenge scopes, and protected-resource
scopes.
scopes_supportedas a fallback only when nocaller-requested or operationally required scopes exist.
offline_accesspolicy and apply the same resultingscope set to preregistered clients, dynamic registration, and the authorization
URL.
with server-required scopes.
The public
select_scopesAPI is unchanged. Discovery remains reactive,consistent with #1052: this change adds no synthetic POST, ping, initialize
request, or additional discovery endpoint.
Regression coverage
Two end-to-end authorization tests cover preregistered and dynamically
registered clients with:
The tests verify stable ordering, deduplication, exclusion of unrelated
authorization-server scopes, preserved
offline_access, reactive GET-onlymetadata discovery for preregistered clients, and identical scopes in the
dynamic-registration request and authorization URL.
Validation
cargo test -p rmcp --features auth --lib transport::auth::tests— 173 OAuthtests passed.
cargo test -p rmcp --features auth,client,transport-io— full package testsand doctests passed.
cargo clippy -p rmcp --features auth,client,transport-io --lib -- -D warnings.rustfmt --check --edition 2024 crates/rmcp/src/transport/auth.rs.git diff --check.Breaking Changes
None. Existing public APIs, registration priority, metadata fallback, and
reactive discovery behavior are preserved.