Repository navigation
fix(den): record the shared callback mode for isolated MCP rows with shared registrations - #4663
Conversation
…shared registrations Callback isolation (July) kept administrator-supplied OAuth clients while flipping rows to isolated-v1. Since registered redirects became authoritative, such a row sends its client's shared redirect but signs the isolated mode, so the shared callback route rejects every transaction after provider consent. connect/start now records shared-v1 on a non-shared row whose pre-registered client recorded the shared callback route as its redirect. The redirect sent to the provider, client registration, credentials, grants, and bindings are unchanged; stale transactions keep failing closed on both routes.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Passed · 1/1 tests · 2/2 assertions · 0 images Commit |
There was a problem hiding this comment.
Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (26fcf20525f79e67e72ce6bde6d02d3613ac0bdf). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run
Test evidence —
|
Problem
Callback isolation (#2868, July) moved qualifying OAuth connections to
isolated-v1and deleted SDK-registered clients, but kept administrator-supplied (pre-registered) clients together with the shared callback recorded as theirregisteredRedirectUri(#2771). Since #4039 made the recorded redirect authoritative, such a row sends the sharedredirect_urito the provider whileconnect/startsigns the row'sisolated-v1mode. After provider consent, the shared callback route rejects the transaction:Every sign-in on an affected connection fails at OpenWork's own callback. No supported surface creates this state today; only rows from the July window carry it.
Change
connect/start: when a row is notshared-v1and its pre-registered client recorded a redirect on the shared callback route (/v1/mcp-connections/oauth/callbackon any public host or base path Den emitted), recordshared-v1on that row inside aFOR UPDATEtransaction before signing state, and logexternal_mcp_oauth_registered_shared_callback_adopted.registeredRedirectUri, tokens, grants, and plugin bindings are untouched. The reconciled row gets the posture a newly created connection for the same provider has today (pinned-transactionmix-up defense without RFC 9207iss,response-issuerwith it).shared-v1, the scoped route still rejects it, and stale transactions signed with the old mode keep failing closed on both routes. SDK-registered clients, rows whose registered redirect is their own scoped callback, and rows with no registered redirect are not touched.docs/external-mcp-oauth.md: one paragraph describing the exception.Out of scope: broad start-time diagnostics for unrelated registered redirects, CORS on error responses, provider approval policies, and the docs hostname for the hosted callback URL (separate follow-up).
Verification
Verdict: Passed. Exact-head assertion evidence for all seven tests is published inline. Head
26fcf20525f79e67e72ce6bde6d02d3613ac0bdf(base4d7727740d222f2291ebb2e6e9005c8bd86b2e16). Direct Vitest PR lane, local cold-boot Den with an isolated MySQL database and the synthetic OAuth+MCP mock; no attached Den, no real provider.pnpm evals:pr specs/mcp-oauth-response-issuer.test.ts— 7 passed, 0 failed, 0 skipped (108 s). The new journeyDen member sign-in recovers an isolated connection whose pre-registered client uses the shared callbackseeds the historical state (pre-registered client viaPOST /v1/mcp-connections, row flipped toisolated-v1through the testkit database), then asserts: admin detail showsisolated-v1with the shared callback URL; a granted member'sconnect/startsends the registered sharedredirect_uriwith the same client id and the detail now readsshared-v1with an unchanged client; the provider redirect lands on the shared route and the callback returns HTTP 200 with exactly one token exchange; the member lists tools with the new credential; replaying the callback is rejected without another exchange. The same spec fails on the base commit at the post-start detail assertion (mode staysisolated-v1).ee/apps/den-api/test/mcp-connections-connect-start.test.ts— 22 pass, 0 fail (bun test --conditions development). New test reproduces the historical sequence throughisolateExternalMcpOAuthCallbackitself, asserts the stale-mode state is rejected by the shared route with the exact message before and after reconciliation and by the scoped route with "connection changed", verifies the token exchange used the shared redirect with the preserved client secret, and keeps a legacy row whose pre-registered client recorded its own scoped callback onlegacy-v1. On the base commit this test fails at the signed state (callbackMode: "isolated-v1").pnpm --filter @openwork-ee/den-api exec tsc --noEmit -p .— clean.pnpm --filter @openwork-ee/den-api test— 24 pass.mcp-connections-edit.test.ts› "marketplace bindings protect identity…" (identityManagedBy provenance) and the Den-as-authorization-server refresh suites fail identically with this change stashed;evalsboundary/channel ratchets andlint:layersreport the same pre-existing debt on base.Live provider behaviour after deployment (consent, token issuance, reviewed-client policy) remains a separate gate; this PR only makes Den's stored callback mode agree with the redirect it already sends.