Repository navigation
Open setup links without a second sign-in, in their workspace - #1452
Merged
Merged
Conversation
A setup link from the chat sent a user who had just signed in to connect Claude to the dashboard login again. The authorization page now leaves a signed, httpOnly cookie with the user and time of that sign-in; /s/<token> opens a dashboard session with it, only for the link's own user, never for a workspace that requires SSO, and not after sessions were revoked. A link now switches the dashboard to the connector's workspace, where saving to a connector in another one was refused with 403, and it opens again for the same user until it expires instead of saying already used.
helpcodeai
enabled auto-merge (squash)
November 2, 2026 16:58
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
What
An end-to-end test of the Claude onboarding on Cloud showed three problems with the setup links the chat tools hand out (
/s/<token>, then the guided setup page):Change
Backend
auth/recent-sign-in.util.ts(new).completeSignIn(the single exit for password, social and dashboard-session sign-ins on the authorization page) setsamcp_signin:POST /api/setup-links/open(no JWT). It opens a link with that cookie only when:sessionsValidFrom;isPasswordLoginBlocked), so the IdP's MFA and Conditional Access still apply;It then returns a dashboard token for the link's workspace, the same token
POST /organizations/switchissues. A link copied out of a chat opens nothing in a browser without the cookie, and the cookie alone opens nothing without a link.POST /api/setup-links/resolve(JWT). When the dashboard session is on another workspace than the connector, it returns a session for the connector's workspace, as the workspace menu would.resolveLink.organizationId.usedAtrecords only the first opening.Frontend
/s/<token>.openfirst and falls back to/login?redirect=….login().proxy.tsandauth-contextno longer bounce/s/to/loginbefore the page can try.Cloud and self-hosted
The behaviour is the same in both modes. The cookie is only sent when the dashboard and the authorization page share a host; with a separate API host,
openanswers 401 and the page falls back to the usual sign-in.Tests
Backend, in
packages/backend:npx jest --maxWorkers=4 src/auth/recent-sign-in.util.spec.ts src/adapters/setup-links.controller.spec.ts src/adapters/connector-setup.service.spec.ts src/auth/login.controller.spec.ts src/auth/login.controller.social.spec.ts: 5 suites passed.open: success, no cookie, link of another account, revoked session, unknown user, unverified e-mail, SSO enforced.resolve: switches workspace, keeps the session on the same workspace, expired link.npx tsc --noEmit -p tsconfig.json: passed.npx eslinton the changed files: clean.Frontend, in
packages/frontend:npx tsc --noEmit -p tsconfig.json: passed.npx eslinton the changed files: no errors; 2 existing warnings inauth-context.tsx.npx playwright test tests/e2e/setup-link.spec.ts: 7 passed. New tests: the workspace switch, and opening with the sign-in just made.