fix(auth): pass the challenge's resource_metadata URL to SDK auth()
An RFC 9728 `WWW-Authenticate: Bearer resource_metadata="…"` challenge was parsed and then dropped by the normalized `AuthChallenge`, so every challenge-driven `mcpAuth()` call ran discovery without it and probed locations derived from the MCP server URL instead. OAuth failed outright against any server whose metadata document lives off the well-known path. The SDK handles this correctly inside its own transports, but the Inspector never reaches that path — it intercepts the 401 and drives `auth()` itself to capture the authorization URL and run the step-up scope union. Carry the advertised URL on `AuthChallenge` as a string (it crosses the web client's remote-backend boundary as JSON), convert it at the OAuth boundary, and pass it to the standard challenge leg, the forced step-up leg, and CIMD pre-registration — which runs before `auth()` and did its own discovery. A malformed value is ignored rather than surfaced, matching the SDK's parser. The callback leg needs nothing: SDK `auth()` persists the URL in its discovery state. Adds an `oauth.resourceMetadataPath` test-server mode that moves the document off the well-known path entirely, so the integration test proves discovery genuinely fails without the fix. Closes #2071 Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
fd1fa06cf5
commit
f8a46726b7
1 changed files with 469 additions and 6 deletions
14
AGENTS.md
14
AGENTS.md
|
|
@ -33,7 +33,19 @@ v2/main/
|
|||
├── core/ # Shared core code (no package.json — consumed via the `@inspector/core` vite alias)
|
||||
│ ├── auth/ # OAuth: providers, discovery, OAuthStorage + persist backends;
|
||||
│ │ # mid-session recovery (challenge.ts WWW-Authenticate
|
||||
│ │ # parsing, scopes.ts SEP-2350 scope union, oauthUx.ts
|
||||
│ │ # parsing — including the RFC 9728
|
||||
│ │ # `resource_metadata` URL, carried on
|
||||
│ │ # AuthChallenge as a STRING because the
|
||||
│ │ # web client's challenge crosses the
|
||||
│ │ # remote-backend boundary as JSON, and
|
||||
│ │ # converted to a URL at the OAuth
|
||||
│ │ # boundary by challengeResourceMetadataUrl
|
||||
│ │ # (malformed values ignored, matching the
|
||||
│ │ # SDK's own parser) so discovery targets
|
||||
│ │ # the advertised document rather than a
|
||||
│ │ # location derived from the MCP server
|
||||
│ │ # URL — #2071;
|
||||
│ │ # scopes.ts SEP-2350 scope union, oauthUx.ts
|
||||
│ │ # shared copy, mcpAuth.ts force-reauthorization,
|
||||
│ │ # issuerBinding.ts SEP-2352 callback-leg failure
|
||||
│ │ # classification — separates a recoverable
|
||||
|
|
|
|||
Loading…
Reference in a new issue