Repository navigation
fix(gateway): harden the SSO login in the TUI and desktop app - #357
Merged
Merged
Conversation
Three fixes from an investigation of the SSO sign-in flow: - The loopback callback server parsed the request URL against the Host header. A malformed Host (any local process can send one) threw inside the request listener, an uncaught exception that took down the TUI or the desktop main process for the length of the sign-in wait. Parse against a fixed 127.0.0.1 base and answer 400 for a target the parser still rejects. - The TUI configure flow quit the whole app on any SSO failure, even from the startup key re-check or /configure on a working install. Quit only on the first-run gate; with a provider connected, toast the reason and close the dialog. /configure opens dismissable on a configured install. - The desktop startup key check prompted for a missing gateway key as well as a rejected one, so every Custom/Connect provider user saw the configure dialog on each launch. Carry the needs-login reason over IPC and prompt for a rejected key only, matching the TUI. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KUxGp8Cs7mMifGyDDWf57b
quickbeard
force-pushed
the
sso-login-fixes
branch
from
September 10, 2026 10:48
0d6cf68 to
65113f4
Compare
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.
Summary
Three fixes from an investigation of the SSO sign-in flow shared by the TUI and the desktop app.
/callbacklistener inpackages/codev-gateway/src/sso.tsbuilt the request URL from theHostheader. A malformed value such asHost: [threw inside the request listener, which is an uncaught exception, and took down the whole process (the TUI, or the Electron main process) during the up-to-five-minute sign-in wait. Any local process can reach the port. The URL is now parsed against a fixedhttp://127.0.0.1base withURL.parse, and a target the parser still rejects gets a400. Regression test added./configureon a working install, where a five-minute login timeout or one failed token exchange killed a session the user was in. The helper now checks whether a provider is connected: quit with the epilogue only when unconfigured, otherwise show the reason as a toast and close the dialog./configurealso opens dismissable on a configured install, like the desktop app's "Get a new API Key".needs-loginreasons, and the Custom/Connect provider paths never write the shared auth file, so an Anthropic or custom-key user saw the dialog on each launch. The reason now travels over IPC and the gate prompts for a rejected key only, matching the TUI.Divergences and docs
DIVERGENCES.md: updated thepackages/tui/src/app.tsxrow for the dismissable/configuredialog. Every other touched file is fork-only.CHANGELOG.md: three entries under Gateway.Test plan
bun testinpackages/codev-gateway(78 pass, including the new malformed-Host test)bun test src/main/gateway-ssoinpackages/desktop(23 pass,no-keyandrejectedreasons asserted)bun test test/configure-gate.test.tsinpackages/tuibun typecheckinpackages/codev-gateway,packages/tui,packages/app,packages/desktop/configureon a configured install, press Escape, then trigger a login failure and confirm the app stays up🤖 Generated with Claude Code
https://claude.ai/code/session_01KUxGp8Cs7mMifGyDDWf57b