Skip to content

feat: browser-based gradient login (#251)#286

Merged
DerDennisOP merged 7 commits into
mainfrom
feat/cli-web-login
May 28, 2026
Merged

feat: browser-based gradient login (#251)#286
DerDennisOP merged 7 commits into
mainfrom
feat/cli-web-login

Conversation

@DerDennisOP
Copy link
Copy Markdown
Member

@DerDennisOP DerDennisOP commented May 28, 2026

Implements the OAuth 2.0 Device Authorization Grant for gradient login so 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-browser skips the browser open for headless/SSH use.
  • New endpoints POST /auth/cli/{start,poll,authorize,deny} and GET /auth/cli/info; pending rows expire after 10 min, the user_code uses an ambiguity-free alphabet, and the device_code is stored hashed.
  • New frontend route /account/cli-authorize reads ?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/login lands the user on the authorize page.

Test plan

  • CI runs the new cargo test -p web --test cli_device_authorization suite (start → poll pending/expired/denied/authorized state machine, auth-required guard on /authorize, deny path).
  • Manual: gradient config server …, gradient login opens the browser, code matches, click Authorize, terminal logs in.
  • Manual: gradient login --no-browser prints the URL and polls successfully when opened on another device.
  • Manual: gradient login --username X --password Y still works (backwards compat).
  • Manual: cancelling in the browser (Deny) makes the CLI exit non-zero.

@DerDennisOP DerDennisOP merged commit 49fb21e into main May 28, 2026
8 checks passed
@DerDennisOP DerDennisOP deleted the feat/cli-web-login branch May 28, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gradient CIi: Webbrowser redirected login

1 participant