fix(auth): cover the CLI refresh path and tighten the well-known match
Two review findings. The stored-token refresh path (`refreshStoredAuthToken`) calls SDK discovery directly rather than through `InspectorClient.effectiveAuthFetch`, so a state file holding a refresh token and client information but no `serverMetadata` still hit the upstream OIDC-schema failure and could not refresh against the very servers this change is for. Its default `discover` now wraps the global fetch with the compat shim; a caller-supplied `fetchFn` is left alone. Covered by a test that injects no `discover` — injecting one would bypass the default under test — against a real server that 404s the RFC 8414 path and serves plain RFC 8414 metadata at the appended OIDC path. `oidcDiscoveryCandidates` matched the well-known path by bare prefix, so it also claimed `/.well-known/oauth-authorization-server-backup` and would have replaced that path's failed response with a document fetched from a derived URL. It now requires the exact path or a `/` boundary, which is precisely the set `buildDiscoveryUrls` can emit. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UL9retfvAXRgvi6EWk4SY4 Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
7ca753bc4c
commit
1db1b9be1f
1 changed files with 116 additions and 1 deletions
|
|
@ -115,6 +115,13 @@ export function oidcDiscoveryCandidates(rfc8414Url: string): string[] {
|
|||
}
|
||||
if (!url.pathname.startsWith(RFC8414_WELL_KNOWN)) return [];
|
||||
const path = url.pathname.slice(RFC8414_WELL_KNOWN.length);
|
||||
// A bare prefix match would also claim `/.well-known/oauth-authorization-server-backup`
|
||||
// — a path this wrapper has no business rewriting, and one whose failed
|
||||
// response it would replace with a document fetched from somewhere else
|
||||
// entirely (Copilot). The SDK appends the authorization server's pathname,
|
||||
// which always begins with `/`, so requiring the exact path or a `/`
|
||||
// boundary is precisely the set it can emit.
|
||||
if (path !== "" && !path.startsWith("/")) return [];
|
||||
// The authorization server had no path, so the SDK emitted a single OIDC
|
||||
// candidate at the origin.
|
||||
if (path === "") return [new URL(OIDC_WELL_KNOWN, url.origin).href];
|
||||
|
|
|
|||
Loading…
Reference in a new issue