Skip to content

feat(cli): sign in with an authorization code and PKCE - #221

Merged
justusschock merged 5 commits into
mainfrom
feat/cli-login-pkce
Nov 2, 2026
Merged

justusschock merged 5 commits into
mainfrom
feat/cli-login-pkce

Conversation

@vivequeramji

@vivequeramji vivequeramji commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor
  • Browser login opens /oidc/authorize for the public lightning-cli client with an S256 challenge and redirect_uri=http://127.0.0.1:{port}/callback. The callback checks state, exchanges the code and verifier at /oidc/token, saves the session and sends the browser to /cli-login-successful. An error, a missing code or a failed exchange sends it to /cli-login-failed.
  • lightning login --no-browser (renamed from --device), and the case where no browser can be opened, use paste-back: the same authorize URL with redirect_uri={LIGHTNING_CLOUD_URL}/cli-login, then a prompt for the code. invalid_grant prompts again, up to three times.
  • Removes login_with_device_code.
  • README and CLI docs updated.

demo

Tests: python/tests/cli (the 9 failures in test_deploy.py and job/test_list.py also fail on the base branch).

vivequeramji and others added 2 commits October 28, 2026 12:20
`lightning login --device` signs in with the OAuth 2.0 device authorization
grant (RFC 8628): it prints a code to enter in a browser on any other device,
polls until the sign-in is approved, and saves the session the same way
`lightning login` does. When `lightning login` can't open a browser, its error
now points at `--device`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Browser login now sends the user to /oidc/authorize for the public
lightning-cli client and receives a single-use code on
http://127.0.0.1:{port}/callback, exchanged with the PKCE verifier at
/oidc/token. `lightning login --no-browser` (and a machine with no
browser) uses paste-back through /cli-login instead of the device code
flow, which is removed.
@vivequeramji
vivequeramji changed the base branch from vivequeramji/device-code-login to main October 29, 2026 18:19
@vivequeramji
vivequeramji enabled auto-merge (squash) October 29, 2026 18:19
Keep the PKCE sign-in where it overlaps the device-code login already on main.
@justusschock
justusschock disabled auto-merge November 2, 2026 19:14
@justusschock
justusschock merged commit bc756b2 into main Nov 2, 2026
24 checks passed
@justusschock
justusschock deleted the feat/cli-login-pkce branch November 2, 2026 19:14
ethanwharris added a commit that referenced this pull request Nov 3, 2026
…IDC_LOGIN is set

#221 switched `lightning login` to the authorization-code login, which
opens /oidc/authorize. The control plane only serves that with
GRID_AUTH_CLI_LOGIN_ENABLED, which production doesn't set yet, so on
v2026.11.02 `lightning login` lands on the web app's 404 page.

`lightning login` goes back to the v2026.10.27 session-token login by
default. LIGHTNING_CLI_OIDC_LOGIN=1 opts in to the authorization-code
login, and to `--no-browser`, for testing against an environment that
serves it. `--no-browser` is hidden from help and refused without the
opt-in, before any saved credentials are cleared. The README and CLI docs
no longer mention it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Harness: claude-code
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.

5 participants