Fix MCP OAuth redirect staying on Twenty dashboard after SSO - #20
Merged
Conversation
The MCP OAuth /authorize page was lost during the SSO round-trip because returnToPath lived only in a Jotai atom destroyed by the full-page navigation to /auth/sso/proxy-login. Thread it as a query parameter so the controller can redirect back after setting the JWT cookie.
LogDetails |
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.
Description
After MCP OAuth login (via SSO proxy-login), users land on the Twenty dashboard instead of being redirected back to the
/authorizeconsent screen. This breaks the MCP client auth flow (Claude Desktop, Cursor).Root cause:
returnToPathis stored in a Jotai atom (in-memory) which is destroyed whenSignInUp.tsxdoes a full-pagewindow.location.replace()to/auth/sso/proxy-login. The controller always redirects to/after setting the JWT cookie.Fix: thread
returnToPathas a query parameter through the proxy-login redirect, so the controller can redirect back to/authorize?...after setting the JWT cookie. The value is validated to prevent open redirect attacks.Testing
https://twenty.<domain>/mcp