Skip to content

Feat/1509 enterprise managed auth - #1512

Merged
cliffhall merged 11 commits into
v2/mainfrom
feat/1509-enterprise-managed-auth
Jun 25, 2026
Merged

cliffhall merged 11 commits into
v2/mainfrom
feat/1509-enterprise-managed-auth

Conversation

@BobDickinson

Copy link
Copy Markdown
Contributor

Summary

Implements Enterprise-Managed Authorization (EMA / XAA) for the web client (#1509 — Phases 1–2 + 3b). When a server has oauth.enterpriseManaged: true, Inspector authenticates against a tenant IdP (install-level config), then mints resource access tokens (legs 2–3) for the server's protected-resource authorization server. Standard OAuth servers are unchanged.

Full design, checklist, staging notes, and test plan: specification/v2_enterprise_managed_auth.md.


New concept: install-level Client Settings

Inspector previously had per-server settings in mcp.json (catalog) and runtime OAuth state (tokens, PKCE, etc.). EMA introduces a third layer: install-level client configuration — settings that apply to the Inspector install as a whole, not to any single MCP server.

The first use case is the Enterprise IdP (OIDC client credentials for legs 1–2). Later this blob can grow (client identity, capability toggles) until a fuller "client profiles" model lands.

Layer What it holds Where it lives Edited via
Server catalog MCP server entries, per-server OAuth resource credentials, enterpriseManaged flag ~/.mcp-inspector/mcp.json Server Settings / import
Client config (new) Enterprise IdP issuer + requesting-app client id/secret; EMA enable/disable ~/.mcp-inspector/storage/client.json Client Settings (gear in header)
Runtime auth state IdP ID Token / refresh, PKCE, per-server resource tokens (tagged enterpriseManaged) Client's OAuthStorage adapter (web: sessionStorage today) Connect / sign-out flows

Important separation: IdP credentials belong in client.json, not in mcp.json or the OAuth token store. Per-server oauth.clientId / clientSecret under EMA mean resource authorization server credentials (leg 3), not IdP credentials.


Client config storage API

Client config uses the same generic storage backend as other install-level blobs (oauth, session stores, etc.):

Store ID HTTP API On disk
client GET / POST / DELETE /api/storage/client ~/.mcp-inspector/storage/client.json

Implementation:

  • core/client/ — ClientConfig types, Zod validation (parseClientConfig / serializeClientConfig), file helpers (loadClientConfig / saveClientConfig → store-io.ts, mode 0o600)
  • core/client/remote.ts — loadClientConfigRemote / saveClientConfigRemote for web (Hono backend in core/mcp/remote/node/server.ts serves /api/storage/:storeId)
  • Web — loads config at session startup (loadClientConfigRemote in App.tsx); Client Settings modal debounces saves via useClientSettingsDraft → saveClientConfigRemote
  • CLI/TUI (Phase 4) — will use NodeClientStorage / loadClientConfig directly; not wired in this PR

On-disk shape (initial):

{
  "enterpriseManagedAuth": {
    "idp": {
      "issuer": "https://idp.example.com",
      "clientId": "inspector-idp-client-id",
      "clientSecret": "inspector-idp-client-secret"
    }
  }
}

Enable/disable: turning off EMA in Client Settings sets enabled: false but retains IdP credentials so re-enable does not require re-entry (isEnterpriseManagedAuthEnabled() / getActiveEnterpriseManagedAuthIdp() in core/client/types.ts).

At connect time, web passes active IdP into InspectorClientOptions.enterpriseManagedAuth and the full install block (including disabled state) as installEnterpriseManagedAuth for error messaging.


EMA auth flow (core)

core/auth/ema/

  • Leg 1 — IdP OIDC authorization code (idpOidc.ts) via existing OAuth stack
  • Leg 2 — ID Token → ID-JAG at IdP (RFC 8693, wire.ts)
  • Leg 3 — ID-JAG → resource access token at resource AS (JWT bearer, wire.ts)
  • Orchestration — emaFlow.ts (trySilentEmaAuth, completeEmaIdpAuthorizationAndMint, 401 refresh)
  • OAuthManager — branches on oauth.enterpriseManaged; quick connect + callback disambiguation
  • EmaTransportOAuthProvider — 401 re-auth (re-run legs 2–3 when IdP session valid)
  • Storage extensions — store-root idpSessions; resource tokens saved with enterpriseManaged: true; sign-out clears IdP session + tagged resource entries (clearEnterpriseManagedResourceServers())
  • getOAuthState() — connection snapshot with protocol: "ema" for Connection Info

Web UX

  • Client Settings (header gear) — Enterprise IdP fields, enable checkbox, IdP login state, sign-out
  • Server Settings — enterpriseManaged checkbox; resource AS client id/secret/scopes; OAuth section hidden for stdio
  • Quick connect — silent path when IdP session cached; otherwise IdP OIDC redirect; shared /oauth/callback (protocol from server config, not OAuth state)
  • Connection Info — OAuth protocol, authorization state, access token copy/JWT decode
  • Errors — EmaClientNotConfiguredError when EMA server but IdP missing/disabled (persistent toast)

Other fixes & infra

  • Keychain migration — renaming a server id migrates keychain secrets (OAuth + stdio env) before delete
  • TUI — AuthTab aligned to OAuthFlowState / getOAuthFlowState() rename (no EMA wiring yet)
  • Test servers — protected-resource mode, external JWT validator, xaa-ema-http.json fixture
  • Phase 3b tests — mock IdP/AS helpers, wire/emaFlow unit tests, inspectorClient-ema-e2e.test.ts
  • Deps — root yaml + vitest alias fix for test-servers config loader

Out of scope (follow-up)

  • Guided EMA (blocked on guided OAuth UX on web)
  • CLI/TUI EMA connect (Phase 4 — will read same client.json via NodeClientStorage)
  • Web → shared RemoteOAuthStorage / oauth.json (IdP sessions survive browser refresh)
  • Optional tests: RemoteOAuthStorage EMA E2E, 401 re-auth integration stretch

Manual staging against live xaa.dev verified (documented in spec §Staging validation).


Test plan

  • npm run validate (web, cli, tui, launcher)
  • npm run test:integration (web)
  • npm run test:storybook (web)
  • Manual: quick EMA connect against xaa.dev staging

Notable automated coverage

  • core/client/ — parseClientConfig, enable/disable semantics
  • clients/web/src/test/core/auth/ema/ — wire + emaFlow
  • clients/web/src/test/integration/mcp/inspectorClient-ema-e2e.test.ts — silent connect, reconnect, enterpriseManaged storage tag
  • clientConfigError, connection-state, OAuthManager EMA not-configured paths
  • servers-route.test.ts — keychain secret migration on server-id rename

@BobDickinson

Copy link
Copy Markdown
Contributor Author

@claude review

@claude

claude Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @BobDickinson's task in 2m 39s —— View job


Review: Enterprise-Managed Authorization (EMA)

I read the core EMA flow (core/auth/ema/*), client-config storage (core/client/*), OAuthManager, the storage/store extensions, the Hono storage/servers routes, and the web wiring (App.tsx, Client Settings). Overall this is a well-structured, carefully-commented PR: the three-leg flow is cleanly separated (wire ↔ emaFlow orchestration ↔ OAuthManager branching), the new install-level config layer is a sensible abstraction, and the test coverage is broad. Standard OAuth paths look untouched. Below are findings, none of which I consider blocking.

Correctness

  1. Public resource clients are blocked despite wire-layer support. mintEmaResourceTokens hard-throws when resourceClientSecret is missing (core/auth/ema/emaFlow.ts:53-57), yet redeemIdJagForAccessToken explicitly supports token_endpoint_auth_method: "none" for a public client (core/auth/ema/wire.ts:171-177). A resource AS that registers Inspector as a public (PKCE/no-secret) client can never reach leg 3. If that's an intentional constraint for now, a comment would help; otherwise the orchestration is stricter than the wire it calls. Fix this →

  2. IdP refresh token is stored but never used. Leg 1 requests offline_access (constants.ts:16) and persists refresh_token into the IdP session (idpOidc.ts:113-117), but nothing ever redeems it. When the ID Token expires, getValidIdToken returns undefined and the user is forced through a full IdP redirect again. Either wire up a refresh-token grant when the ID Token is expired, or drop offline_access + the unused field to avoid implying capability that isn't there. (PR lists web→shared storage as follow-up, so a follow-up is fine — worth tracking.)

  3. Token expiry only considers JWT exp, not expires_in. isAccessTokenUsable (transportProvider.ts:15-21 and connection-state.ts:22-25) calls isJwtExpired, which returns false for any non-JWT token (jwt.ts:33 — exp === undefined). An opaque resource access token, or a JWT issued with only expires_in, is therefore treated as never-expiring and only refreshed reactively on a 401. That's a reasonable fallback, but the standard expires_in is silently ignored — worth a comment so the next reader doesn't assume proactive refresh covers all tokens.

  4. Silent path can't distinguish "needs login" from "mint failed." trySilentEmaAuth swallows every error and returns false (emaFlow.ts:91-99). When the IdP session is valid but legs 2–3 fail for a config reason (e.g. wrong resource client secret), authenticateEnterpriseManaged (oauthManager.ts:173-196) treats the false as "log in again" and redirects to the IdP, only surfacing the real mint error after the round-trip. Consider letting the silent path signal why it failed so a misconfig surfaces immediately instead of after a redirect.

Security

  1. IdP clientSecret is persisted in plaintext in client.json while per-server OAuth secrets go to the OS keychain. This is an asymmetry with the keychain path in servers.ts (extractSecretsFromStored / KeyringSecretStore). Mode 0o600 mitigates it and the PR documents the choice, but a confidential-client IdP secret is arguably the most sensitive credential in the install. Recommend routing it through the same SecretStore in a follow-up, and calling out the plaintext-on-disk behavior in the spec's security notes.

  2. POST /api/storage/:storeId does no server-side schema validation (core/mcp/remote/node/server.ts:820-843) — client.json is validated only client-side via parseClientConfig. A malformed blob on disk makes loadClientConfigRemote throw parseClientConfig, which App.tsx catches and silently resets to {} — so a hand-edited/corrupt client.json would quietly disable EMA with no user-visible signal. Consider surfacing the parse error rather than swallowing it.

Minor / cleanup

  1. Issuer normalization is duplicated. issuer.replace(/\/$/, "") is inlined ~7 times across emaFlow.ts, idpOidc.ts, and wire.ts, while normalizeIdpIssuer already exists (idpSession.ts:7-9). Consolidating on the helper removes drift risk (e.g. if normalization ever needs to also lowercase the host).

  2. App.tsx connect calls getActiveEnterpriseManagedAuthIdp(clientConfig) twice (once in the spread condition, once with a ! non-null assertion). Compute it once into a local const activeIdp and branch on that — cleaner and drops the assertion.

  3. connect useCallback depends on the whole clientConfig object, which loads async after mount. Connecting before it resolves means an EMA server throws EmaClientNotConfiguredError (handled gracefully with a toast), so not a bug — but a brief note on the dep would help, since the callback identity churns once on initial config load.

Tasks

  • Read core EMA auth flow (core/auth/ema/)
  • Review client config storage (core/client/)
  • Review OAuthManager + storage changes
  • Review web UX wiring (App.tsx, Client Settings)
  • Check security (secret handling, token storage)
  • Post review

Nice work on this — the layering and the inline rationale comments make it easy to follow. The items above are refinements, not blockers.
· branch feat/1509-enterprise-managed-auth

@BobDickinson

Copy link
Copy Markdown
Contributor Author

Those are some good findings. I'll address them before merge.

@BobDickinson BobDickinson added auth Issues and PRs related to authorization v2 Issues and PRs for v2 labels Jun 24, 2026
@BobDickinson
BobDickinson marked this pull request as draft June 24, 2026 04:56
@BobDickinson

Copy link
Copy Markdown
Contributor Author

Claude Review Follow-up

Fixed

Review item What we did
IdP refresh token unused getValidIdToken / refreshIdpOidcSession redeem refresh_token when the ID Token is expired. offline_access is now meaningful.
Silent path swallows mint errors trySilentEmaAuth returns success / no_idp_session / mint_failed. Valid IdP session + legs 2–3 failure throws immediately instead of redirecting to the IdP.
Corrupt client.json silently → {} Load failure shows a persistent toast with formatClientConfigLoadError. App still boots with {}. No server-side JSON validation on generic POST /api/storage/:storeId (by design).
Issuer normalization duplicated Consolidated on normalizeIdpIssuer in core/auth/ema/storage.ts; wire.ts and idpOAuthStorageKey use it.
Double getActiveEnterpriseManagedAuthIdp in App.tsx Hoisted to activeIdp in setupClientForServer.
IdP clientSecret plaintext in client.json Same pattern as per-server OAuth secrets: secret in OS keychain (client:idp-client-secret), stripped config on disk, rehydrate on GET, migrate legacy plaintext on first read.

Not fixed (intentional)

Public resource client blocked

Review: emaFlow requires resourceClientSecret; wire supports token_endpoint_auth_method: "none" for public AS clients.

Why deferred: xaa.dev resource registration is a confidential client (secret required). No deployment in scope needs a public/no-secret resource AS. wire.ts already supports none when we have one.

expires_in / opaque resource access tokens

Review: Proactive expiry uses JWT exp only; opaque tokens and expires_in-without-exp are treated as never-expiring until a 401.

Why deferred:

  • Leg-3 resource tokens from xaa are JWTs with exp — proactive refresh works today.
  • Opaque tokens have no self-contained expiry; expires_in is relative to AS issuance, not an absolute time in the token string.
  • On expiry we 401 → re-run legs 2–3 (IdP session valid) → retry. Worst case: one extra failed request, not a broken session.
  • Proactive expires_in would need a client-side receipt-time anchor, which is heuristic, not AS-authoritative.

clientConfig in setupClientForServer useCallback deps

Review: Whole clientConfig object in deps causes callback identity to change once when async load completes.

Why no change: Not a bug. clientConfig starts as {} and loads from /api/storage/client after mount. Connect before load → EmaClientNotConfiguredError + toast. After load or Client Settings save, the callback must update to pass new IdP creds. One extra identity refresh on load is expected.

Summary

All user-visible correctness issues from the review are addressed. Remaining items are deployment assumptions (confidential resource client, JWT resource tokens) or acceptable fallbacks (401 refresh, async config load). Safe to merge with PR comments explaining the three deferred items above.

@BobDickinson
BobDickinson marked this pull request as ready for review June 24, 2026 07:08
@BobDickinson
BobDickinson requested a review from cliffhall June 24, 2026 07:08
@cliffhall cliffhall linked an issue Jun 24, 2026 that may be closed by this pull request
@cliffhall

Copy link
Copy Markdown
Member

@BobDickinson Resolving conflicts and will review / smoke test.

…se-managed-auth

# Conflicts:
#	clients/web/src/App.tsx
#	clients/web/src/components/groups/ServerSettingsForm/ServerSettingsForm.tsx
#	clients/web/src/components/groups/ServerSettingsModal/ServerSettingsModal.stories.tsx
#	clients/web/src/components/groups/ServerSettingsModal/ServerSettingsModal.test.tsx
#	clients/web/src/components/groups/ServerSettingsModal/ServerSettingsModal.tsx
#	clients/web/src/test/core/mcp/serverList.test.ts
#	core/mcp/remote/node/server.ts
#	core/mcp/serverList.ts
@cliffhall

Copy link
Copy Markdown
Member

@claude review

@claude

claude Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @cliffhall's task in 3m 47s —— View job


Review: EMA — follow-up round

I re-reviewed the current branch state, focused on verifying the six fixes from the prior round and hunting for anything new. I read the core/auth/ema/* flow, core/client/* (incl. the new keychain path), the Hono storage route, and the web wiring. Net: the follow-up fixes all landed correctly, and I found no blockers. A handful of minor refinements below.

✅ Prior-round fixes — all verified correct

  • IdP refresh token now redeemed: getValidIdToken → refreshIdpOidcSession on expiry (idpOidc.ts), with safe fallback to undefined on failure. offline_access is now meaningful.
  • Silent-path error discrimination — trySilentEmaAuth returns success | no_idp_session | mint_failed; oauthManager.ts branches on all three, so a valid-session mint failure surfaces immediately instead of redirecting.
  • Issuer normalization consolidated on normalizeIdpIssuer.
  • Corrupt client.json now raises a persistent toast via formatClientConfigLoadError (App.tsx, autoClose: false) instead of silently → {}.
  • Double getActiveEnterpriseManagedAuthIdp hoisted to a single activeIdp in setupClientForServer.
  • IdP clientSecret → keychain: verified the round-trip. Secret is stripped via destructuring before writeStoreFile (secrets.ts), legacy plaintext is migrated and removed from disk, GET rehydrates from keychain, and keychain-unavailable degrades gracefully on read / hard-fails (503) on write. Sign-out clears only enterpriseManaged-tagged resource entries, leaving standard OAuth tokens intact. Good.

Investigated and dismissed

  • "Debounced save races with sign-out" — not a bug. logout() (useEmaIdpLoginState.ts:43) clears the IdP runtime session in OAuthStorage; the debounced save persists IdP credentials to client.json — separate stores. Re-saving issuer/clientId after sign-out is the intended "retain credentials on disable" behavior, and it can't restore the cleared session tokens. No ordering hazard.

New findings (all minor / non-blocking)

  1. Client-config validation errors return 500, not 400 (and aren't formatted on the save path). server.ts:848-863 — a ZodError from writeClientConfigStore → parseClientConfig falls through to the generic Failed to write store: … 500. The formatClientConfigLoadError helper only runs on the load path, so a bad POST body surfaces as a raw 500 string. In practice the Client Settings form builds valid config so this is hard to hit, but a malformed body is a client error — return 400 and reuse the formatter. Fix this →

  2. Concurrent IdP token refresh has no in-flight dedup. getValidIdToken (idpOidc.ts) — two near-simultaneous callers that both see an expired ID Token will each fire a refresh_token grant. Harmless functionally (one may lose the refresh-token-rotation race and fall back to a redirect), but a single shared in-flight promise would avoid the duplicate IdP round-trip. Low priority. Fix this →

  3. normalizeIdpIssuer import source split — idpOidc.ts imports it from ./idpSession.js (a re-export) while wire.ts imports from ./storage.js (the canonical source). Harmless, but worth pointing both at storage.js so the indirection doesn't confuse the next reader.

  4. Partial-write split state (low, self-healing). In writeClientConfigStore (node-persistence.ts), the keychain set precedes the disk write; if the disk write fails after the keychain set, secret-in-keychain / stale-on-disk diverge briefly. It recovers on the next save (migration is idempotent), so just noting it.

None of these block merge — they're robustness refinements on top of an already-solid implementation. Nice work tightening up the refresh and keychain paths since the last round.
· branch feat/1509-enterprise-managed-auth

…date normalizeIdpIssuer import

Addresses two non-blocking findings from the Claude review on #1512:

- POST /api/storage/client now returns 400 (not a generic 500) with the
  load-path formatting when parseClientConfig throws a ZodError on a malformed
  body. A bad body is a client error; the keychain/500 path is unchanged for
  genuine write failures. Adds an integration test for the 400 path.
- idpOidc.ts imports normalizeIdpIssuer from its canonical source ./storage.js
  (matching wire.ts) instead of the ./idpSession.js re-export.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@cliffhall

Copy link
Copy Markdown
Member

Thanks for the thorough re-review. Responding to each finding — note this round's commit (504439aa) is on top of the v2/main merge (4e714ddf) I pushed to resolve conflicts; the review's findings are all in the EMA feature itself, which the merge left intact.

#1 — Client-config validation returns 500 instead of 400 ✅ Fixed in 504439aa.
POST /api/storage/:storeId now catches ZodError from parseClientConfig and returns 400 with the same formatClientConfigLoadError formatting the load path uses (e.g. enterpriseManagedAuth.idp.issuer: …), instead of falling through to the generic Failed to write store 500. The keychain-error and 500 branches are unchanged for genuine write failures. Added an integration test (client-store-route.test.ts) asserting a malformed body → 400, formatted message, and no partial write to disk/keychain.

#3 — normalizeIdpIssuer import source split ✅ Fixed in 504439aa.
idpOidc.ts now imports normalizeIdpIssuer from its canonical ./storage.js (folded into the existing idpOAuthStorageKey import), matching wire.ts. Left the ./idpSession.js re-export in place since connection-state.ts still imports it there alongside getEmaIdpLoginState (which genuinely lives in idpSession), so pointing that one at storage.js would just split its import for no gain.

#2 — Concurrent IdP token refresh has no in-flight dedup — Deferred (acknowledged).
Agreed it's a real refinement, but as noted it's functionally harmless (the loser falls back to a redirect) and a shared in-flight promise touches the refresh-rotation path, which I'd rather not change in a merge/cleanup PR without dedicated test coverage. Tracking as a follow-up.

#4 — Partial-write split state in writeClientConfigStore — Deferred (acknowledged).
Self-healing and idempotent on next save, as you noted. Reordering disk-write-before-keychain (or a compensating rollback) is a reasonable hardening but out of scope here; noting for a follow-up.

The merge itself (conflict resolution across serverList.ts, the server validator, and the Server Settings components/tests) is verified green: typecheck, lint, 1998 unit + 676 integration tests, plus a manual Playwright smoke test (configure stdio server → connect → tools/list → tools/call round-trip).

@cliffhall

Copy link
Copy Markdown
Member

@claude review

@claude

claude Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @cliffhall's task in 1m 29s —— View job


Review: EMA — verification of 504439aa

Re-reviewed the branch on top of the v2/main merge (4e714ddf), focused on the two fixes in 504439aa and a scan for anything new. Both fixes landed correctly and are tested; no blockers.

✅ Fixes verified

  • Progress notifications #1 — 400 on malformed client config. POST /api/storage/:storeId now catches ZodError and returns 400 with formatClientConfigLoadError(...), before the keychain/500 fallbacks (core/mcp/remote/node/server.ts:864-866; imports at :67/:69). The keychain-error and genuine-write-failure branches are untouched. Covered by client-store-route.test.ts:171 — asserts 400, formatted message, and no partial write to disk/keychain. Good: the ZodError check is correctly ordered ahead of keychainErrorResponse, so a bad body can't be misclassified as a keychain failure.
  • Completion requests #3 — import source consolidated. idpOidc.ts:16 now pulls normalizeIdpIssuer from the canonical ./storage.js (folded into the existing idpOAuthStorageKey import), matching wire.ts:16. Leaving the ./idpSession.js re-export for connection-state.ts is the right call — it imports getEmaIdpLoginState from there too, so repointing it would split that import for no gain.

Spot-checks (clean)

  • Keychain round-trip in node-persistence.ts / secrets.ts re-read: strip-on-write (writeClientConfigStore), rehydrate-on-read, legacy-plaintext migration (write keychain → strip disk), and else-branch keychain delete when the secret is cleared all hold. extractSecretsFromClientConfig destructures clientSecret out cleanly.
  • getValidIdToken → refreshIdpOidcSession refresh path and trySilentEmaAuth's success | no_idp_session | mint_failed discrimination are intact after the merge.

Carry-over (still appropriately deferred — not re-raising)

  • Request logging #2 concurrent IdP refresh dedup and SSE transport support #4 keychain/disk partial-write remain acknowledged follow-ups. deleteClientConfigStore has the same shape as SSE transport support #4 in reverse (disk delete precedes keychain delete → a failed keychain delete orphans the secret), self-healed on next write — fine to fold into the same follow-up.

One tiny nit (optional, non-blocking)

  • emaFlow.ts:69 still inlines ctx.resourceAsUrl.href.replace(/\/$/, "") to build the audience. It's normalizing a resource-AS URL href, not an IdP issuer string, so it's genuinely outside normalizeIdpIssuer's scope — but if you want zero inline trailing-slash trims left in this folder, a small shared stripTrailingSlash helper would cover both. Purely cosmetic.

Net: the follow-up commit does exactly what it claims, with a test for the new 400 path. LGTM from my side.
· branch feat/1509-enterprise-managed-auth

@cliffhall

Copy link
Copy Markdown
Member

Thanks — appreciate the verification pass.

  • Progress notifications #1 / Completion requests #3 — glad they check out, including the ordering of the ZodError branch ahead of keychainErrorResponse.
  • Request logging #2 / SSE transport support #4 (+ the symmetric deleteClientConfigStore disk-before-keychain delete you spotted) — agreed, folding all three into a single self-healing-ordering follow-up.
  • Nit (emaFlow.ts:69 inline trailing-slash trim) — leaving as-is. As you note it's normalizing a resource-AS URL href, not an issuer, so it's outside normalizeIdpIssuer's scope and a shared stripTrailingSlash helper would be purely cosmetic. Not worth churn in this PR.

Calling the merge + the two follow-up fixes done here. Thanks for the review.

@cliffhall

cliffhall commented Jun 25, 2026 •

Copy link
Copy Markdown
Member

Manual EMA smoke test (web, browser-driven)

Following up the earlier generic-connectivity smoke: this one exercises the enterprise-managed authorization flow itself — the actual feature of this PR — driven through the web UI with Playwright.

Topology

A standalone harness (scripts/ema-smoke-harness.mjs) stands up the same three servers the EMA e2e integration test uses, but as long-lived processes the running Inspector can reach:

  • mock enterprise IdP — OIDC discovery + RFC 8693 token-exchange (leg 2)
  • mock resource AS — discovery + JWKS + JWT-bearer grant (leg 3)
  • protected-resource MCP server (built TestServerHttp) — validates the minted access token

The web client proxies all OAuth/EMA fetches through its Node backend (createRemoteFetch → /api/fetch), so the backend reaches the 127.0.0.1 mock servers server-to-server (no CORS), and the EMA OAuth logic itself runs browser-side from the live source.

Steps & results

  1. Client Settings → Enterprise-Managed Authorization — enabled enterprise IdP config (issuer + client id/secret); persisted to client.json.
  2. Server Settings → OAuth — added the protected MCP server, enabled Enterprise-managed authorization, set the resource-AS client id/secret/scope.
  3. Connect — silent EMA: cached IdP session → Connected, no interactive OAuth redirect.
  4. Network tab — shows the full 3-leg EMA exchange: IdP discovery + token-exchange (:7300/token), resource-AS discovery + JWT-bearer grant (:7301/token), then the authenticated MCP connection (:7302/mcp).
  5. Authenticated tool call — echo returned Echo: EMA authenticated call OK, proving the EMA-minted bearer token authorizes real MCP requests.

Honest caveats

  • IdP session was seeded (silent-EMA path), exactly like the e2e test does — the mock IdP has no interactive login page, so the interactive leg-1 IdP login was not exercised here. The token-mint legs (2–3) and authenticated session are fully real.
  • Per-server enterpriseManaged checkbox didn't persist under Playwright automation. The text fields (client id / secret / scopes) persisted fine, but the Enterprise-managed authorization checkbox's onChange didn't register through synthetic clicks, so I set oauth.enterpriseManaged: true in mcp.json directly to proceed. Likely a Playwright synthetic-event artifact rather than a product bug — please confirm with a real manual click before trusting it.

Screenshots

1 — Client Settings: Enterprise-Managed Authorization configured

ema-01-client-settings

2 — Server OAuth Settings: Enterprise-managed authorization enabled

ema-02-server-oauth-settings

3 — Connected via EMA

ema-03-connected

4 — Network log: the 3-leg EMA token exchange

ema-04-network-legs

5 — Authenticated tool call

ema-05-authenticated-tool-call

Automated coverage (for reference)

EMA also has automated tests, green on this branch: inspectorClient-ema-e2e.test.ts (silent EMA via cached IdP session + legs 2–3, reuse, enterpriseManaged-tagged token persistence) plus unit tests (emaFlow, idpOidc, idpSession, wire, clientConfigError).

@cliffhall
cliffhall merged commit 5de4e91 into v2/main Jun 25, 2026
1 check passed
@cliffhall
cliffhall deleted the feat/1509-enterprise-managed-auth branch June 25, 2026 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auth Issues and PRs related to authorization v2 Issues and PRs for v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Enterprise-Managed Authorization

2 participants