feat: bound every OAuth-path request with a deadline
Protected-resource-metadata discovery, authorization-server metadata discovery, dynamic client registration, the token exchange and the refresh all went out with no AbortSignal at all. Token revocation was the single exception, and its withDeadline race is the pattern this generalizes. Adds core/auth/requestTimeout.ts: withOAuthRequestTimeout wraps a fetch so every call through it is bounded, composing any caller signal with AbortSignal.any and racing a timer so the deadline holds even where the signal is dropped in flight (the browser's remote fetch re-issues the call to /api/fetch and forwards no signal). The rejection is an OAuthRequestTimeoutError naming the URL, so a stall says which endpoint stalled rather than riding the SDK handshake timeout and reporting "Request timed out". Applied inside InspectorClient.buildEffectiveAuthFetch rather than to this.fetchFn, because the transport is handed this.fetchFn directly and a deadline on a Streamable HTTP / SSE response would sever the stream it is supposed to hold open. Also applied to the CLI's storedAuthFetch, which calls SDK discovery directly and so has nothing else bounding it. Closes #2319 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YFnM6RqB4nXqNysgUYmjmq Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
d8b4b06af9
commit
8dd7bc2920
1 changed files with 362 additions and 2 deletions
|
|
@ -256,6 +256,7 @@ import {
|
|||
} from "../auth/challenge.js";
|
||||
import { withOAuthEndpointOverrides } from "../auth/endpointOverrides.js";
|
||||
import { withRfc8414OidcCompat } from "../auth/oidcDiscoveryCompat.js";
|
||||
import { withOAuthRequestTimeout } from "../auth/requestTimeout.js";
|
||||
import type { TokenRevocationOutcome } from "../auth/revocation.js";
|
||||
import type { OAuthTokens } from "@modelcontextprotocol/client";
|
||||
import { silentLogger, type InspectorLogger } from "../logging/logger.js";
|
||||
|
|
@ -991,7 +992,15 @@ export class InspectorClient extends InspectorClientEventTarget {
|
|||
}
|
||||
|
||||
private buildEffectiveAuthFetch(): typeof fetch {
|
||||
const base = this.fetchFn ?? fetch;
|
||||
// #2319: bound every OAuth-path request — discovery, dynamic client
|
||||
// registration, the token exchange, the refresh. Applied here rather than
|
||||
// to `this.fetchFn` because the transport is handed `this.fetchFn`
|
||||
// directly, and a deadline on a Streamable HTTP / SSE response would sever
|
||||
// the very stream it is supposed to hold open. The cost of that placement
|
||||
// is that the discovery the SDK runs from *inside* the transport (the
|
||||
// 401/refresh path) is not covered here; that leg sits inside an SDK
|
||||
// request and is bounded by its per-request timeout.
|
||||
const base = withOAuthRequestTimeout(this.fetchFn ?? fetch);
|
||||
// Capture auth response bodies (OAuth discovery, DCR, token exchange) so
|
||||
// they're inspectable in the Network tab. Token-exchange responses carry
|
||||
// `access_token` / `refresh_token`; the Network UI masks those (and other
|
||||
|
|
|
|||
Loading…
Reference in a new issue