Repository navigation
fix(mcp): scope stored OAuth grants to the client registration - #2666
Conversation
Signed-off-by: Alex Gercog <[email protected]>
|
Warning
Pull request policy: Only bug fixes may be opened as pull requests. |
|
No actionable comments were generated in the recent review. WalkthroughMCP OAuth token storage now supports keys scoped to server and client identity fields. OAuth discovery records issuer and resource metadata. The provider prepares authentication with the current endpoint and registration state, and tests cover namespace isolation, registration changes, and grant reuse. ChangesMCP OAuth grant storage and authentication
Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix · Severity of issue fixed: Low Sequence Diagram(s)sequenceDiagram
participant MCPOAuth2Provider
participant OAuth2AuthCodeFlowProvider
participant ObjectStoreTokenStorage
participant ObjectStore
MCPOAuth2Provider->>OAuth2AuthCodeFlowProvider: prepare provider and authenticate
OAuth2AuthCodeFlowProvider->>ObjectStoreTokenStorage: retrieve grant for user
ObjectStoreTokenStorage->>ObjectStore: read namespaced token key
ObjectStore-->>ObjectStoreTokenStorage: stored token
ObjectStoreTokenStorage-->>OAuth2AuthCodeFlowProvider: grant
Merge Risk:
|
|
/ok to test e39eca7 |
|
/merge |
Description
Stored MCP OAuth grants were keyed by user id alone, so a grant saved by one client registration was returned to a later registration that shared the object store. Grants are now stored under a namespace derived from the registration: the MCP server, the authorization server issuer and endpoints, the client id, the resource and the requested scopes.
Reopening the same registration reuses its grant, and rotating the client secret keeps it. A changed client id, resource, issuer or server starts a new authorization. MCP workers write
tokens/v2/{namespace_hash}/{user_hash}; callers that constructObjectStoreTokenStoragewithout a namespace keep reading and writingtokens/{user_hash}. Existing records are left untouched, and the first use after the upgrade authorizes again. The token storage guide describes mixed-version workers and the retirement of old keys.ci/scripts/run_tests.pypasses 68 selected tests in the MCP project and 29 in the core project. The tests use synthetic credentials and in-memory object storage; a deployed provider was not used.This touches
auth_provider.py, as does the issuer check proposed for #2664. Whichever lands second needs a rebase, and I will do it.Closes #2663
By Submitting this PR I confirm:
Summary by CodeRabbit