Repository navigation
fix(auth): a new CIMD authorization keeps the user's other grants - #441
Closed
matthewhenry-cf wants to merge 1 commit into
Closed
matthewhenry-cf wants to merge 1 commit into
matthewhenry-cf wants to merge 1 commit into
Conversation
A CIMD client ID and its redirect URI are shared by every connection a hosted client holds (one metadata URL, one callback), so the provider's default grant replacement revoked a user's other live connections whenever they authorized again. Their next refresh failed with 'Grant not found'. Registered (DCR) clients get a client ID per install and keep replacement.
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.
Problem
A CIMD client ID is the client's metadata document URL, so every install of the client shares it. A hosted client also shares one redirect URI across all of its connections. When
completeAuthorization()replaces existing grants (the defaultrevokeExistingGrants: true), workers-oauth-provider revokes every grant for that user that matches client ID, redirect URI and resource. For a hosted CIMD client, that's all of the user's other live connections (oauth-provider.ts#L6750-L6767).Result: connecting a second time, for example from a second agent, revokes the first connection's grant. Its next refresh fails with
invalid_grant: Grant not found, and reconnecting it then revokes the other one. The revocation also runs before the client exchanges the new code (#L6829-L6836), so even an abandoned authorization breaks the existing connection.Change
Pass
revokeExistingGrants: falsefor CIMD clients. Registered (DCR) clients get a client ID per install, so they keep replacement.Tradeoffs
refreshTokenTTLruns out or the client revokes them (RFC 7009). The fixed TTL caps how many build up.Tests
New test in
tests/auth/cimd.test.ts: two full CIMD authorizations for the same user keep 2 grants, and both refresh tokens return 200. Before this change it fails because only 1 grant remains. The full suite passes (894 tests).Spec alignment
The specs neither require nor forbid replacing earlier grants on re-authorization. It's authorization-server policy. This change brings that policy in line with how CIMD identifies clients.
client_ididentify?client_ididentifies the application, shared by every user and connection. It is not an installation.client_idis "a brand new client".Grant not founditself a violation?MCP now prefers CIMD and deprecates DCR as of
2026-07-28(client registration). So more clients will share oneclient_idacross many users and connections, and this policy will affect more of them. It isn't specific to one client: the same matching applies to any hosted agent platform where one user holds several connections. DCR clients still get oneclient_idper registration, so they keep replacement.Follow-up worth considering: the same default lives in
workers-oauth-provider, so other MCP servers built on it with CIMD enabled have the same behavior.