fix(local,cli,react): replace token-in-URL bootstrap with a one-time-code exchange - #1889
Open
ra-co88 wants to merge 1 commit into
Open
fix(local,cli,react): replace token-in-URL bootstrap with a one-time-code exchange#1889ra-co88 wants to merge 1 commit into
ra-co88 wants to merge 1 commit into
Conversation
ra-co88
force-pushed
the
fix/otc-bootstrap
branch
4 times, most recently
from
August 30, 2026 18:58
19b2e24 to
f749ae1
Compare
ra-co88
force-pushed
the
fix/otc-bootstrap
branch
from
August 30, 2026 19:11
f749ae1 to
79b83d7
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.
What
The local bootstrap flow replaces the bearer-token-in-URL with a one-time-code exchange: the CLI mints a single-use code (bearer-gated), the browser redeems it at
/api/auth/exchange, and the daemon hands back the session credential. The code dies with the process and is consumed on first use.Why
The previous bootstrap put the long-lived bearer token directly in the URL — leaking it through browser history, referrer headers, and process listings. A one-time code that is exchanged server-side and never persists means a leaked URL is worthless after first use (and worthless at all if unused before the daemon exits — the store is instance-bound).
What changed
otc.ts: in-memory single-use code store, instance-bound.POST /api/auth/otc(bearer-gated mint) andPOST /api/auth/exchange(one-time redeem) in the local server.?_token=URL is still accepted for compatibility, but the token is exchanged out of the URL immediately rather than persisted in it.Rebased over #1865 (the long-poll OAuth await endpoint landed in the same file); the routes are independent.
Test plan
Exchange suite: mint→redeem succeeds once, replay fails, cross-instance code fails, malformed body rejected. 5 tests green against current main. Local boot verified end-to-end: CLI prints the code URL, exchange returns the bearer, mint returns a fresh code, and the fresh code redeems to the same bearer.