feat: browser-based gradient login (#251)#286
Merged
Conversation
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.
Implements the OAuth 2.0 Device Authorization Grant for
gradient loginso the CLI no longer needs to handle a password directly: the user confirms the session in their browser instead.Closes #251.
Summary
gradient login(no args) starts a device flow: prints the verification URL + a short confirmation code, opens the browser, then polls until the user authorizes from/account/cli-authorize.gradient login --username … --password …keeps the current scriptable basic-login path;--no-browserskips the browser open for headless/SSH use.POST /auth/cli/{start,poll,authorize,deny}andGET /auth/cli/info; pending rows expire after 10 min, the user_code uses an ambiguity-free alphabet, and thedevice_codeis stored hashed./account/cli-authorizereads?code=, prompts the user to confirm origin IP / user-agent, and exposes Authorize / Deny buttons. The login page now honors?next=so the redirect back from/account/loginlands the user on the authorize page.Test plan
cargo test -p web --test cli_device_authorizationsuite (start → poll pending/expired/denied/authorized state machine, auth-required guard on/authorize, deny path).gradient config server …,gradient loginopens the browser, code matches, click Authorize, terminal logs in.gradient login --no-browserprints the URL and polls successfully when opened on another device.gradient login --username X --password Ystill works (backwards compat).