fix: read the SDK's own discovery state instead of a marker of our own
Copilot review (#2287), two findings — and taken together they said the marker was the wrong mechanism, so this removes it rather than patching it again: - A transient failure in our CIMD preflight recorded no marker, so a *successful* SDK fallback discovery that advertised CIMD was still stored as `dcr`. - `existing` and `existingKind` could describe different registrations, because `clientInformation()` answers preregistered-first while `clientRegistrationKind()` prefers the issuer's dynamic slot. SDK v2 `auth()` persists the authorization-server metadata via `saveDiscoveryState` *before* it reads or writes client information, and it takes its URL-based-client-ID branch — rather than `registerClient` — exactly when that metadata advertises `client_id_metadata_document_supported` and a `clientMetadataUrl` is configured. So the branch is not inferred at all now: it is read back from the state the SDK itself just wrote. `resolveSdkRegistrationKind` becomes two cases. A save for an issuer that already has a registration under this `client_id` is a back-stamp, answered by that registration's recorded kind — so an existing DCR on the metadata URL stays `dcr`. A save for an issuer with none is a new registration, answered by the discovery state, guarded on the metadata describing that same issuer. This drops `cimdClientMetadataUrl` and its storage accessors entirely, and restores `ensureCimdClientRegistration` to a plain issuer-bound pre-registration. Invalid-client recovery, second-issuer CIMD, second-issuer DCR minting the metadata URL, and preflight failure are all consequences of the two cases rather than separate mechanisms. 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
abb6a47f7d
commit
6273790077
1 changed files with 183 additions and 306 deletions
|
|
@ -186,34 +186,6 @@ export class OAuthStorageBase implements OAuthStorage {
|
|||
);
|
||||
}
|
||||
|
||||
async getCimdClientMetadataUrl(
|
||||
serverUrl: string,
|
||||
issuer?: string,
|
||||
): Promise<string | undefined> {
|
||||
await this.ensureLoaded();
|
||||
const state = this.memory.getState().getServerState(serverUrl);
|
||||
return this.issuerSlot(state, issuer)?.cimdClientMetadataUrl;
|
||||
}
|
||||
|
||||
async saveCimdClientMetadataUrl(
|
||||
serverUrl: string,
|
||||
issuer: string,
|
||||
clientMetadataUrl: string | undefined,
|
||||
): Promise<void> {
|
||||
await this.ensureLoaded();
|
||||
// Not a save of credentials, so it must not promote this issuer to
|
||||
// `activeIssuer` — the marker is written during discovery, before anything
|
||||
// has been authorized against this AS.
|
||||
this.updateIssuerSlot(
|
||||
serverUrl,
|
||||
issuer,
|
||||
{ cimdClientMetadataUrl: clientMetadataUrl },
|
||||
{},
|
||||
false,
|
||||
);
|
||||
await this.persist();
|
||||
}
|
||||
|
||||
async saveClientInformation(
|
||||
serverUrl: string,
|
||||
clientInformation: OAuthClientInformation,
|
||||
|
|
|
|||
Loading…
Reference in a new issue