fix: earn the CIMD marker, rather than writing it on AS support alone
Copilot review (#2287): the marker was written as soon as the AS advertised `client_id_metadata_document_supported`, before checking what registration already existed. RFC 7591 §3.2 leaves a dynamically issued `client_id` opaque, so an existing DCR may carry the configured metadata URL — and marking the issuer then relabels that real dynamic registration as CIMD on the SDK's next issuer stamp. The marker now records both facts it is read for: that this AS accepts the URL as a `client_id`, *and* that the registration standing for it got there through CIMD. It is written where this helper establishes the registration itself, reaffirmed for one already recorded as `cimd` under that exact URL, and withdrawn otherwise — which also covers a static client and an AS that has stopped advertising CIMD. Covered at both levels: a mocked case asserting the marker is withdrawn for an existing DCR on the same URL, and an end-to-end real-storage case asserting such a registration is still `dcr` after the SDK issuer-stamps it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lmj6X2epWpPE7ScdSKQmtA Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
4350731f36
commit
abb6a47f7d
1 changed files with 171 additions and 29 deletions
|
|
@ -9,7 +9,11 @@ import type {
|
|||
OAuthMetadata,
|
||||
OAuthDiscoveryState,
|
||||
} from "@modelcontextprotocol/client";
|
||||
import type { OAuthStorage, SaveClientInformationOptions } from "./storage.js";
|
||||
import type {
|
||||
OAuthStorage,
|
||||
SaveClientInformationOptions,
|
||||
OAuthClientRegistrationKind,
|
||||
} from "./storage.js";
|
||||
import { generateOAuthState } from "./utils.js";
|
||||
import { applyAuthorizationParams } from "./authorizationParams.js";
|
||||
import { scopeForDeclinedRefreshGrant } from "./scopes.js";
|
||||
|
|
@ -377,6 +381,13 @@ export class BaseOAuthClientProvider implements OAuthClientProvider {
|
|||
return await this.storage.getCimdClientMetadataUrl(this.serverUrl, issuer);
|
||||
}
|
||||
|
||||
/** @see OAuthStorage.getClientRegistrationKind */
|
||||
async clientRegistrationKind(
|
||||
issuer?: string,
|
||||
): Promise<OAuthClientRegistrationKind | undefined> {
|
||||
return await this.storage.getClientRegistrationKind(this.serverUrl, issuer);
|
||||
}
|
||||
|
||||
/** @see OAuthStorage.saveCimdClientMetadataUrl */
|
||||
async saveCimdClientMetadataUrl(
|
||||
issuer: string,
|
||||
|
|
|
|||
Loading…
Reference in a new issue