fix(oauth): route zed-hosted native-app callback back to the dashboard port - #10517
Open
phatchau036 wants to merge 2 commits into
Open
fix(oauth): route zed-hosted native-app callback back to the dashboard port#10517phatchau036 wants to merge 2 commits into
phatchau036 wants to merge 2 commits into
Conversation
Zed's native-app sign-in always redirects the browser to the loopback port sent as native_app_port (hardcoded default 58443), where nothing listens: the browser shows "site can't be reached" and the login looks broken even though the token is in the URL. The manual paste fallback was broken too - handleManualSubmit requires a ?code= param that Zed's callback (user_id + access_token) never carries, so the flow could never complete. - zed-hosted: derive native_app_port from the dashboard's own loopback port so the redirect lands back on OmniRoute; remote/LAN origins keep the old default port and the paste flow - app root: forward ?user_id=...&access_token=... to the /callback relay instead of dropping the query string on the /dashboard redirect - /callback relay: recognize the Zed payload (no code param) and relay the full URL as the exchange payload; allow postMessage to both loopback spellings (localhost/127.0.0.1) of the same port - OAuthModal: zed-hosted popup auto-completes on true localhost; the manual paste path passes the full URL through to the exchange instead of erroring with "No authorization code found" - manual input panel: zed-hosted-specific placeholder and hint - tests: extend the postMessage scope guard with the loopback same-port trusted origins
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
zed-hostedprovider's native-app sign-in always redirects the browser tohttp://127.0.0.1:<native_app_port>/?user_id=...&access_token=.... That port was the hardcoded default58443, so after signing in at zed.dev the browser lands on a dead port ("site can't be reached") and the login looks broken — even though the access token is right there in the URL.handleManualSubmitrequires a?code=param that Zed's callback never carries, so pasting the URL always failed with "No authorization code found".native_app_portfrom the dashboard's own loopback port so the redirect lands back on OmniRoute, forwards the root/query to the/callbackrelay, teaches the relay to recognize the Zed payload, and fixes the manual paste path for zed-hosted.Flow after the fix (true localhost): Connect → popup at zed.dev → Zed redirects to
127.0.0.1:<dashboard-port>/?user_id=...&access_token=...→ root handler forwards to/callback→ relay postMessages the full URL → modal exchanges it (RSA-decrypts with the authorize-time private key) and saves the connection. LAN/remote deployments keep the dead-port redirect and the (now working) manual paste flow.Related Issues
Validation
npm run lint— not run locally (same reason)main@ca23eed; all six touched files verified byte-identical to that base before editingTests Added Or Updated
tests/unit/ui/oauth-callback-postmessage-scope.test.tsx— trusted-origin set extended with the loopback same-port variants (http://localhost:<port>/http://127.0.0.1:<port>), keeping the feat: WebSocket proxy support on /v1/responses for Codex CLI compatibility #998 no-wildcard guarantee assertions intact.Coverage Notes
/callbackrelay origin change is covered by the updated postMessage scope test. ThebuildAuthUrlport derivation and the modal paste-path dispatch are exercised by the existing zed/oauth-modal suites in CI; no dedicated new unit test asserts the port derivation yet (noted below).Reviewer Notes
createZedNativeAuthDataalways sendsnative_app_port(default 58443) and Zed ignores any redirect_uri/path, redirecting to the loopback root. Separately, the root page (/) 307-redirects to/dashboardand drops the query string, so even landing on the dashboard port would have lost the payload — hence the forward-to-/callbackhandler.resolveDashboardLoopbackPortonly acceptshttp:loopback redirect URIs; https/remote/LAN origins keep the old default port and the paste flow, so no remote behavior changes.trustedTargetOriginsare both spellings of the operator's own machine on the same port (localhost vs 127.0.0.1) — the same rationale as the existing 1455 entries; a hostile local app would be on a different port and still never receives the code.