[WEBXP-469] Add circleci signup command with hybrid browser flow#1196
Open
Fab10-CircleCi wants to merge 1 commit intoCircleCI-Public:mainfrom
Open
Conversation
Implements a signup command using Pete's cross-origin token delivery approach. The browser stays on app.circleci.com the entire time — the frontend creates a PAT and delivers it to the CLI's localhost server via a cross-origin fetch(). - Ephemeral HTTP server on 127.0.0.1:0 with single /token endpoint - CORS middleware pinned to https://app.circleci.com - Access-Control-Allow-Private-Network header for Chrome PNA - State validation via cli_state param (namespaced to avoid Auth0 collision) - Error handling for PAT creation failures from frontend - --no-browser fallback for headless/SSH environments - --force flag to bypass already-authenticated guard - Telemetry events and workflow step tracking - 17 unit tests Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Checklist
=========
Internal Checklist
Changes
=======
circleci signupcommand with hybrid browser flow for CLI authentication127.0.0.1:0with single/tokenendpointapp.circleci.com/authentication/loginwithreturn-topointing to/successful-signup(relative path — no Auth0 config changes needed)https://app.circleci.comwithAccess-Control-Allow-Private-Network: truefor Chrome PNAfetch()tohttp://127.0.0.1:PORT/tokencli_stateparam (namespaced to avoid Auth0 collision)errorquery param)--no-browserflag for headless/SSH environments (prints URL, prompts for manual PAT paste)--forceflag to bypass already-authenticated guardcli-signup) and workflow step trackingroot_test.gosubcommand count from 29 to 30Rationale
=========
This implements the CLI side of the hybrid browser signup flow (WEBXP-469, follow-up from WEBXP-417). The goal is to let new users run
circleci signup, complete signup in the browser, and have the CLI automatically authenticated — no manual token copy-paste required.Based on Pete's feedback, the browser never navigates to localhost. Instead, the frontend page on
app.circleci.comcreates a PAT and delivers it directly to the CLI's local server via a cross-originfetch(). Thereturn-tois a relative path (/successful-signup?source=cli&cli_port=PORT&cli_state=STATE) so it passes the existing domain whitelist with zero backend/Auth0 changes.Frontend counterpart: circleci/web-ui-consolidated#6482
Considerations
==============
localhost/127.0.0.1as "potentially trustworthy" per the W3C spec, allowing HTTPS→HTTP fetches. Chrome additionally requiresAccess-Control-Allow-Private-Network: true(PNA header) which is included.Access-Control-Allow-Originheader is set to exactlyhttps://app.circleci.com— never*.cli_state(notstate) to avoid collision with Auth0's own state parameter in the redirect chain.circleci setupas fallback.crypto/rand,net/http,net/url,pkg/browser— all already in the project.🤖 Generated with Claude Code