Repository navigation
feat(auth): name a configured routed site origin in Desktop sign-in answers - #256
Merged
Merged
Conversation
…nswers A deployment reached through an edge router on another site origin gets requests with its own Host, so api_url / apiUrl / verification_uri named the API or dashboard origin and a Desktop that signed in through the routed site refused them. SELFHOST_ROUTED_SITE_URL (optional https origin) adds a third configured origin. When a request carries exactly one x-original-host header naming that origin's host, the seven Desktop/CLI sign-in answers name it. The header only selects the configured value and is never echoed. Emailed links, OIDC redirect URIs, the MCP endpoint URL, browser origin checks and cookies keep the Host-selected origin. Unset: no change. Co-Authored-By: Claude <noreply@anthropic.com>
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
Conflicts in CHANGELOG.md and openapi.yaml resolved by keeping both sides. Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
Author
|
Hold lifted on the maintainer's word. Main was merged in (conflicts in CHANGELOG.md and openapi.yaml, both sides kept); checks are green on this head. |
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.
What
A deployment can be reached through an edge router on another site origin that forwards
<site>/cloud/...to this service. Those requests arrive with this service's ownHost, so the sign-in answers named the API or dashboard origin. Agent Relay Desktop compares those values with the site it signed in to and refuses the sign-in when they differ (browser handoffapi_url, deviceverification_uri, device and enrollment tokenapi_url).This adds one optional setting,
SELFHOST_ROUTED_SITE_URL(an https origin without credentials, path, query or fragment). When a request carries exactly onex-original-hostheader whose value, trimmed and lower-cased, equals that origin's host, seven Desktop/CLI answers name the configured origin instead of the Host-selected one. Unset (the default), nothing changes.Design
,), an array value, or any other host falls back to the Host-selected origin.x-original-hostitself. The setting is confined to answers where that is harmless (see the table); every place where the origin would matter to someone other than the caller keeps the Host-selected origin.x-original-hostwith its own site's host instead of passing a client's copy through. This is documented, but nothing here depends on it for safety.Every caller of
siteBaseUrl, and the call made for eachapi_urlquery value (cli/login)redirect_uri;api_urlis a query value read by the Desktop that started the sign-in. A direct caller that forges the header only makes its own Desktop see the configured public origin.POST auth/desktop/session,apiUrlno-store.POST auth/desktop/workspaces,apiUrlPOST auth/device/start,verification_uriandverification_uri_completePOST auth/device/token,api_urlPOST auth/enrollment/token,api_urlPOST auth/token/refresh,apiUrldescribe_capabilities)redirect_uriIn all seven "yes" rows the value goes only to the caller that sent the header, is an operator-configured public origin, scopes no cookie, is not stored, and is never the target of a redirect this service sends. Telling a direct caller the routed site's name tells it where the operator already publishes the service.
Not covered
Tests
test/desktop-site-origin.test.ts: through the router (browser handoff, exchange, refresh, device start and token); direct through each configured site with the setting on; header variants (case and space variant matches; another host, a comma-joined value, two values and a repeated value fall back, and the foreign host never appears in any answer); setting unset; MCP endpoint URL unchanged; workspace switch; enrollment key exchange.test/config.test.ts: the setting's parsing and refusals.Local, one job at a time:
tsc -p tsconfig.json --noEmitclean;test/desktop-site-origin.test.ts13/13;test/config.test.ts24/24.No migration. Docs:
docs/repository-guide.md(setting table and a new section),openapi.yaml,CHANGELOG.md.Held with
merge-train:hold: not to be merged without the maintainer's word.🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Summary by cubic
Fixes Desktop sign-in for deployments reached through an edge router on another site origin. Those requests arrive with this service's own Host, so the sign-in answers named the API or dashboard origin, and a Desktop that signed in through the routed site refused them.
Adds optional
SELFHOST_ROUTED_SITE_URL(an https origin). When a request carries exactly onex-original-hostheader naming that origin's host, seven Desktop/CLI sign-in answers — browser handoffapi_url, desktop session and workspace switchapiUrl, device startverification_uriandverification_uri_complete, device and enrollment tokenapi_url, and refreshapiUrl— name the configured origin instead. Unset (the default), nothing changes.x-original-hostwith its own site's host.Written for commit fe17332. Summary will update on new commits.