Repository navigation
feat(auth): continue a Fabric MCP authorization after sign-in, and keep linked routes stable - #2125
Open
dawsontoth wants to merge 2 commits into
Open
dawsontoth wants to merge 2 commits into
dawsontoth wants to merge 2 commits into
Conversation
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>
|
Commit |
Coverage Report
File Coverage |
dawsontoth
marked this pull request as ready for review
November 18, 2026 21:02
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
⊙ 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 dropredirectentirely, so the user must click Connect again. The connector also links into Studio routes nothing keeps stable.💡 Solution
/oauth/mcp/authorize?…in place of the sign-in page. A signed-in user goes straight there.//.🤔
location.replace, notlocation.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 astatethe client has already used. So every path replaces the entry. Switching back is a one-line change tofollowServerRedirect; the signed-in guard's router redirect replaces either way.⚖️ Alternatives
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.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)
postSignInRedirect.tsis the one place that decides what aredirectmay be. A server target is exactly/oauth/mcp/authorize, with or without a query, at most 2,048 characters, with no control character, space,\or#. An in-app target starts with/but not//or/\, is not under/oauthin any case, and has no control character.followServerRedirectreplaces the entry.useCloudSignIn.ts: a password sign-in follows the target, and an unverified one carries it to/verifying.CheckOAuth.tsx: an OAuth sign-in follows the target, and a failed one goes back to sign-in with it. Its sign-in bookkeeping is now guarded, as inuseCloudSignIn, so a throw there cannot strand the user before the redirect.routes.ts(auth): a signed-in visit to/#/sign-in?redirect=…goes straight on through the router'sreloadDocumentredirect, which replaces the entry. Local Studio's sign-in uses the in-app check.getOAuthSignInUrl.ts,GoogleAuthenticationButton.tsxandGitHubAuthenticationButton.tsx: the buttons send/#/check-oauth?redirect=…as their return URL, and leave off a value they would not follow.SignIn.tsx,SignUp.tsx,ForgotPassword.tsxandVerifying.tsxcarry the target on every link and navigation between the sign-in pages.cluster/routes.ts,useClusterInstanceSignIn.tsandFinishSetup.tsxuse the in-app check. Finish Setup used to throw on a non-textredirectafter creating the admin user.Stable routes (#2102)
stableRoutes.tsis the list, with the rule for moving a page: add the new path and keep the old one as a redirect route. The router DESIGN note carries the rule, and the root index points at it.The stable routes (hash routes on
https://fabric.harper.fast/#)/,/new-org,/{organizationId},/{organizationId}/new-cluster,/{organizationId}/{clusterId}with/instances,/usage,/scaling,/edit/version, and/{organizationId}/{clusterId}/instance/{instanceId}/{organizationId}/{clusterId}/apps; deployments/{organizationId}/{clusterId}/config/deploymentsand…/config/deployments/{deploymentId}; logs/{organizationId}/{clusterId}/logs; payment methods/{organizationId}/billing/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,oxlintanddprint checkare clean.postSignInRedirect.test.tscovers the open-redirect cases: other hosts,//,/\, script and data URLs, longer and sibling paths, other/oauthendpoints, encoded%2F/%3F/dot segments, control characters, fragments, the length limit, and non-text values.signedInSignInRedirect.test.tsruns the real route tree: a signed-in user's page is replaced by the authorization, and hostile values never load.stableRoutes.test.tsresolves every entry against the real route tree and checks its page and parameters. Renamingusageturns it red.Page and hook tests for each hand-off
CheckOAuth.test.tsx(including a throwing bookkeeping step),useCloudSignIn.test.tsx(and the/verifyinghand-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./#/sign-in?redirect=<authorize URL>gave Google, GitHub and Sign up links that decode back to the exact target. A//evil.exampleredirect appeared in no link. With no session,/#/check-oauth?redirect=…returned to/#/sign-in?redirect=…. The oauth plugin's ownsanitizeRedirect(2.12.0) kept the return URL intact./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
0b5598190dbabfc3minor correctness —src/features/auth/hooks/useCloudSignIn.ts— MCP redirect lost when sign-in/sign-up continues via emailed verify or reset link — filed Sign-in: keep a Fabric MCP authorization through emailed verify and reset links, and on sign-up while signed in #21231ab41d9f466ad5afminor correctness —src/features/auth/routes.ts— sign-up route lacks the signed-in redirect guard sign-in has — filed Sign-in: keep a Fabric MCP authorization through emailed verify and reset links, and on sign-up while signed in #2123Review-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