-
Notifications
You must be signed in to change notification settings - Fork 454
11-25-2025 compliant Auth #651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- add WWWAuthenticateParams for parsing scope and resource_metadata from headers - add ScopeUpgradeConfig and scope tracking in AuthorizationManager - add InsufficientScopeError and 403 handling in streamable HTTP client - add scope union computation for progressive authorization - export new public types: AuthClient, ScopeUpgradeConfig, WWWAuthenticateParams Co-authored-by: fizy069 <fizy069@users.noreply.github.com>
|
Idea: conformance could be used to test against a live server. Some of the other SDK projects test against it in CI, e.g. https://github.com/modelcontextprotocol/python-sdk/blob/main/.github/workflows/conformance.yml |
Will leave this up to @alexhancock to tackle in a separate PR probably. Unless you'd like me to add here. Don't want it to be bigger than it needs to be |
Bring the SDK's OAuth implementation into compliance with MCP Authorization Spec 2025-11-25 and wire up automatic scope selection and upgrade flows.
As discussed with @alexhancock in #641
Motivation and Context
The SDK's OAuth implementation targeted the 2025-03-26 spec and was missing several features from the 2025-11-25 revision:
SDK consumers also had to manually manage scope selection and handle scope upgrade flows. This change makes those automatic.
How Has This Been Tested?
cargo test -p rmcp --lib --all-features)Breaking Changes
AuthorizationMetadatahas a new fieldcode_challenge_methods_supported: Option<Vec<String>>. Code that constructs this struct with explicit fields (not..Default::default()) will need to add the field. Thecomplex_auth_streamhttpexample has been updated accordingly.handle_response()now returnsAuthError::InsufficientScopeon 403 witherror="insufficient_scope"in the WWW-Authenticate header, andAuthError::AuthorizationFailed("Forbidden")for other 403 responses. Previously all non-401 responses were passed through asOk.Types of changes
Checklist
Additional context
This incorporates work from PR #595 by @fizy069 (SEP-835 scope handling). The relevant commits include a Co-authored-by trailer to preserve attribution.
Security vs compatibility philosophy: the SDK defaults to correct spec behavior but falls back gracefully for non-compliant servers, except where the fallback would be insecure. PKCE S256 is always enforced (never falls back to plain or no challenge). RFC 8707 resource parameter is always sent but the flow continues if the server ignores it.
The
select_scopes()priority chain follows SEP-835:scopefrom WWW-Authenticate headerscopes_supportedfrom Protected Resource Metadata (RFC 9728)scopes_supportedfrom AS metadataPassing empty scopes to
start_authorization()triggers auto-selection using this chain.