[WEBXP-417] Add circleci signup command with hybrid browser flow#1195
Draft
Fab10-CircleCi wants to merge 3 commits intoCircleCI-Public:mainfrom
Draft
[WEBXP-417] Add circleci signup command with hybrid browser flow#1195Fab10-CircleCi wants to merge 3 commits intoCircleCI-Public:mainfrom
Fab10-CircleCi wants to merge 3 commits intoCircleCI-Public:mainfrom
Conversation
Implements a new signup command that opens the browser to CircleCI's signup page and receives the authentication token back via a local HTTP server callback, with error handling for PAT creation failures and a --no-browser fallback for manual token entry. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove HTML bridge page (handleCallback) — browser stays on circleci.com - Frontend creates PAT and delivers it via cross-origin fetch to localhost - Add CORS middleware pinned to https://app.circleci.com - Rename handleComplete → handleToken, single /token endpoint - Use cli_state/cli_port params to avoid collision with Auth0's state - Build signup URL via url.Values with relative return-to path - Update --no-browser to point to login page with token settings return-to - Update tests: remove handleCallback tests, add CORS tests Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…mand 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
=======
newSignupCommandtocmd/signup.gowith hybrid browser flow for CLI authentication127.0.0.1:0with/callbackand/completeendpointshttps://circleci.com/signup?source=cli&state=<hex>&return-to=http://127.0.0.1:<port>/callback/callbackthat reads URL fragment (#token=...&state=...) and relays to/completevia fetch#error=token_creation_failed&state=...) from frontend PAT creation failures/complete, store token in~/.circleci/cli.ymlon success--no-browserflag that prints signup URL and prompts for manual PAT pastecli-signup) and workflow step tracking (browser_opening,token_received,failed,timeout)signupcommand incmd/root.gocmd/signup_unit_test.goRationale
=========
This PR implements the CLI side of the hybrid browser signup flow (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.The frontend counterpart (also WEBXP-417) modifies
successful-signup.tsxto detectsource=cli+ localhostreturn-to, create a PAT viaPOST /api/v1/user/token, and redirect back to the CLI's local server with the token in the URL fragment.Considerations
==============
#token=...) are never sent to the server by the browser, so the/callbackendpoint serves an HTML page with JavaScript that readswindow.location.hashand relays the values to/completeviafetch. This is the standard pattern for implicit-grant-style flows.#error=token_creation_failedif PAT creation fails. The JavaScript detects this and forwards the error to/completeso the CLI exits immediately with a helpful message instead of silently timing out for 5 minutes.circleci setupas fallback.crypto/rand,net/http,pkg/browser— all already in the project.🤖 Generated with Claude Code