Skip to content

feat(auth): continue a Fabric MCP authorization after sign-in, and keep linked routes stable - #2125

Open
dawsontoth wants to merge 2 commits into
stagefrom
claude/mcp-fabric-connector-fixes-363d71
Open

dawsontoth wants to merge 2 commits into
stagefrom
claude/mcp-fabric-connector-fixes-363d71

Conversation

@dawsontoth

@dawsontoth dawsontoth commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor
A fox ranger shows friends the one lit path back to the gate a traveler came from

⊙ Problem

The Fabric MCP connector (central-manager#1206) sends a signed-out user to /#/sign-in?redirect=/oauth/mcp/authorize?…. Studio ignores that target, and Google and GitHub sign-ins drop redirect entirely, so the user must click Connect again. The connector also links into Studio routes nothing keeps stable.

💡 Solution

  • After a password, Google or GitHub sign-in to Fabric, Studio loads /oauth/mcp/authorize?… in place of the sign-in page. A signed-in user goes straight there.
  • Only that exact path on this origin is followed; no other server path, host or //.
  • Google and GitHub sign-ins now keep in-app redirects too.
  • One list names the routes central-manager links to; a test checks each still resolves to its page.
  • Not covered: emailed verify and reset links carry only a token, so those land on the default route; retrying from Claude works (Sign-in: keep a Fabric MCP authorization through emailed verify and reset links, and on sign-up while signed in #2123).

🤔 location.replace, not location.assign?

The issue asked for assign. With it, Back from the client's callback reaches a sign-in page that finds the new session and loads the authorization again with a state the client has already used. So every path replaces the entry. Switching back is a one-line change to followServerRedirect; the signed-in guard's router redirect replaces either way.

⚖️ Alternatives

  • Build the authorize URL from VITE_CENTRAL_MANAGER_API_URL: central-manager only sends this redirect to the Studio it serves itself, so the page's own origin is the authorization server.
  • Ask a signed-in user to confirm before continuing: the oauth plugin already shows its own consent page for every client.
  • Allow a list of server paths, or any same-origin path: authorize is the only one central-manager sends today, and a list is easy to grow when it sends another.
  • Keep the redirect in browser storage across the OAuth round trip: the fragment already survives central-manager's sanitizeRedirect. Storage is what Sign-in: keep a Fabric MCP authorization through emailed verify and reset links, and on sign-up while signed in #2123 needs for emailed links, which open in a new tab.

🔧 Changes

Following a redirect (#2101)

Stable routes (#2102)

The stable routes (hash routes on https://fabric.harper.fast/#)
Linked from Routes
Connector, today /, /new-org, /{organizationId}, /{organizationId}/new-cluster, /{organizationId}/{clusterId} with /instances, /usage, /scaling, /edit/version, and /{organizationId}/{clusterId}/instance/{instanceId}
Connector, write tools applications /{organizationId}/{clusterId}/apps; deployments /{organizationId}/{clusterId}/config/deployments and …/config/deployments/{deploymentId}; logs /{organizationId}/{clusterId}/logs; payment methods /{organizationId}/billing
Emails and OAuth /sign-in, /sign-up, /check-oauth, /verify-email, /reset-password

✅ Verification

  • pnpm test: 736 files and 8,919 tests pass, run by the commit hook on each commit. tsc -b, oxlint and dprint check are clean.
  • postSignInRedirect.test.ts covers the open-redirect cases: other hosts, //, /\, script and data URLs, longer and sibling paths, other /oauth endpoints, encoded %2F/%3F/dot segments, control characters, fragments, the length limit, and non-text values. signedInSignInRedirect.test.ts runs the real route tree: a signed-in user's page is replaced by the authorization, and hostile values never load.
  • stableRoutes.test.ts resolves every entry against the real route tree and checks its page and parameters. Renaming usage turns it red.
  • Each new guard was removed in turn, and a test went red every time.
Page and hook tests for each hand-off

CheckOAuth.test.tsx (including a throwing bookkeeping step), useCloudSignIn.test.tsx (and the /verifying hand-off), SignIn.test.tsx, SignUp.test.tsx, ForgotPassword.test.tsx, Verifying.test.tsx, FinishSetup.test.tsx, getOAuthSignInUrl.test.ts, and the Google and GitHub button tests.

  • In the browser (dev server, signed out), /#/sign-in?redirect=<authorize URL> gave Google, GitHub and Sign up links that decode back to the exact target. A //evil.example redirect appeared in no link. With no session, /#/check-oauth?redirect=… returned to /#/sign-in?redirect=…. The oauth plugin's own sanitizeRedirect (2.12.0) kept the return URL intact.
  • Not run end to end: Claude → /oauth/mcp/authorize → Studio → back needs a central manager with MCP enabled (central-manager#1206 is a draft).

🤖 Generated by Claude Code (Claude Opus 5.5); posted via @dawsontoth.

Related PRs: #2054 overlaps (merged; this extends the check-oauth return URL and handoff it added)
Complexity: medium

Deferred findings

Review-Coverage: authored=claude; ran=cursor-composer,gemini,codex; late=cursor-grok:failed; adjudicated=domain; blocked=cursor-grok(failed); declined=muse; rounds=4; full=3 @ b357c78

Review-Attention: deep ~25m (sensitive: CheckOAuth.tsx, ForgotPassword.tsx +8; decisions: server-target-allowlist, app-target-refuses-oauth-namespace, replace-not-assign, do-less-alternative) @ b357c78

dawsontoth and others added 2 commits November 18, 2026 15:09
The Fabric MCP connector's sign-in (central-manager's @harperfast/oauth
mcp.sessionLogin) sends a signed-out user to
/#/sign-in?redirect=/oauth/mcp/authorize?... and expects them back there.
Studio only ever followed an in-app redirect, and the Google and GitHub
buttons dropped it altogether, so the user had to click Connect again.

- postSignInRedirect decides what a redirect may be: an in-app route, or
  exactly /oauth/mcp/authorize followed by its query, on this origin. No
  other server path, scheme, host, //, backslash, control character,
  fragment or over-long value is followed, and nothing else under /oauth
  becomes an in-app route. Every sign-in flow reads redirect through it.
- The MCP target is followed with a full-page load that replaces the
  sign-in entry, after a password or OAuth sign-in and for a user who is
  already signed in. Back then cannot reach a sign-in page that would load
  the authorization again with a state the client has already used.
- The Google and GitHub buttons carry redirect into /#/check-oauth, which
  the CM keeps through the OAuth round trip. That also fixes in-app
  redirects for OAuth sign-ins. Sign-in, sign-up, forgot password, the
  check-your-email page and a failed OAuth check keep it on the way
  between pages. The emailed verify and reset links carry only a token,
  so those continuations still land on the default route (#2123).
- The cluster, instance, Local Studio and Finish Setup pages use the same
  in-app check, so a repeated or non-text redirect no longer reaches
  navigate() (Finish Setup threw on one after creating the admin user).
- CheckOAuth guards its sign-in bookkeeping the way useCloudSignIn does,
  so a throttled replaceState or a broken analytics script no longer
  strands a signed-in user before the redirect.

Fixes #2101

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Central-manager links people into Studio: the Harper Fabric MCP
connector's tool results (src/lib/studioLinks.js), its emails, and its
OAuth plugin's sign-in. A route rename silently sends every one of those
links to a dead page.

stableExternalRoutes lists them, including the cluster's applications,
deployments and logs pages and the organization's billing page that the
connector's upcoming write tools will link to. A test resolves each entry
against the real route tree and checks it lands on its page, with its
parameters. The router DESIGN note says a rename must keep a redirect
from the old path.

Fixes #2102

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

hdbms preview: https://claude-mcp-fabric-connector-fixes-363d71.app.dev.studio.harperfabric.com/

Commit b357c78, workflow run. It updates on each push and is removed when this PR closes.

@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 85.96% 23329 / 27138
🔵 Statements 85.77% 24765 / 28873
🔵 Functions 81.98% 6502 / 7931
🔵 Branches 81.48% 20404 / 25039
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/features/auth/CheckOAuth.tsx 98% 78.57% 100% 97.95% 31
src/features/auth/ForgotPassword.tsx 96.29% 100% 88.88% 96% 63
src/features/auth/SignIn.tsx 86.66% 71.42% 66.66% 85.71% 108-115
src/features/auth/SignUp.tsx 86.66% 71.42% 87.5% 88.37% 136-140
src/features/auth/Verifying.tsx 83.33% 100% 50% 83.33% 22-26
src/features/auth/routes.ts 71.05% 60% 52.63% 71.05% 44-51, 59, 65, 72, 79, 86, 93
src/features/auth/components/GitHubAuthenticationButton.tsx 100% 100% 100% 100%
src/features/auth/components/GoogleAuthenticationButton.tsx 100% 100% 100% 100%
src/features/auth/hooks/useCloudSignIn.ts 98.07% 89.47% 100% 98.03% 146
src/features/auth/hooks/useClusterInstanceSignIn.ts 35.29% 0% 33.33% 35.29% 29-51
src/features/cluster/FinishSetup.tsx 85.36% 80.76% 100% 84.61% 68-69, 72-73, 123, 129
src/features/cluster/routes.ts 80.48% 100% 63.63% 80.48% 21, 29, 36, 44, 52, 60, 116, 124
src/lib/urls/getOAuthSignInUrl.ts 100% 90% 100% 100%
src/lib/urls/postSignInRedirect.ts 100% 100% 100% 100%
src/router/stableRoutes.ts 100% 100% 100% 100%
Generated in workflow #2615 for commit b357c78 by the Vitest Coverage Report Action

@dawsontoth
dawsontoth marked this pull request as ready for review November 18, 2026 21:02
@dawsontoth
dawsontoth requested a review from a team as a code owner November 18, 2026 21:02

This branch was successfully deployed

2 active deployments
hdbms-preview — b357c78e Deployed Nov 18, 2026 by github-actions[bot]
preview — b357c78e Deployed Nov 18, 2026 by dawsontoth via deploy #13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant