feat(auth): per-server authorization and token URL overrides
Adds two optional per-server fields — `oauth.authorizationUrl` and `oauth.tokenUrl` — that override the endpoints authorization-server metadata discovery resolved, so a server can be pointed at a development or staging authorization server without changing what it advertises. SDK v2 routes both endpoints through the discovered metadata document and neither through OAuthClientProvider, so the override is applied by wrapping the client's base fetch and patching the metadata document in flight (core/auth/endpointOverrides.ts). Wrapping the base fetch — rather than only the auth fetch — also covers the discovery the SDK runs from inside the transport on the 401/refresh path. The fields round-trip through mcp.json, the /api/servers routes, the runner (CLI/TUI), and the Server Settings → Authorization panel, where a value that is not an absolute http(s) URL is flagged inline; at runtime such a value is dropped with a single warning rather than failing the connection. Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
6bc355df63
commit
364d8c9dbc
1 changed files with 1212 additions and 6 deletions
|
|
@ -11,7 +11,10 @@ import type {
|
|||
InspectorClientOptions,
|
||||
InspectorServerSettings,
|
||||
} from "../mcp/types.js";
|
||||
import { oauthAuthorizationParamsFromSettings } from "../mcp/serverList.js";
|
||||
import {
|
||||
oauthAuthorizationParamsFromSettings,
|
||||
oauthEndpointOverridesFromSettings,
|
||||
} from "../mcp/serverList.js";
|
||||
import { loadClientConfig } from "./config.js";
|
||||
import type { ClientConfig } from "./types.js";
|
||||
import {
|
||||
|
|
@ -74,6 +77,9 @@ export function buildRunnerClientAuthOptions(
|
|||
const serverAuthorizationParams = savedSettings
|
||||
? oauthAuthorizationParamsFromSettings(savedSettings)
|
||||
: undefined;
|
||||
const serverEndpointOverrides = savedSettings
|
||||
? oauthEndpointOverridesFromSettings(savedSettings)
|
||||
: undefined;
|
||||
|
||||
const oauthFromServer =
|
||||
savedSettings &&
|
||||
|
|
@ -81,6 +87,7 @@ export function buildRunnerClientAuthOptions(
|
|||
savedSettings.oauthClientSecret ||
|
||||
savedSettings.oauthScopes ||
|
||||
serverAuthorizationParams ||
|
||||
serverEndpointOverrides ||
|
||||
savedSettings.enterpriseManaged)
|
||||
? {
|
||||
...(savedSettings.oauthClientId && {
|
||||
|
|
@ -95,6 +102,7 @@ export function buildRunnerClientAuthOptions(
|
|||
...(serverAuthorizationParams && {
|
||||
authorizationParams: serverAuthorizationParams,
|
||||
}),
|
||||
...serverEndpointOverrides,
|
||||
...(savedSettings.enterpriseManaged && {
|
||||
enterpriseManaged: true,
|
||||
}),
|
||||
|
|
|
|||
Loading…
Reference in a new issue