Skip to content

feat: Add device auth login#828

Merged
lox merged 2 commits into
mainfrom
lox/auth-login-device
Jun 3, 2026
Merged

feat: Add device auth login#828
lox merged 2 commits into
mainfrom
lox/auth-login-device

Conversation

@lox
Copy link
Copy Markdown
Contributor

@lox lox commented May 12, 2026

Problem

bk auth login currently assumes a browser can be opened on the same machine that is running the CLI and that a localhost callback can be reached. That is awkward or impossible in common headless cases, especially SSH sessions, remote development boxes, and other environments where the user can authorize in a separate browser but cannot rely on loopback browser OAuth.

Buildkite now has OAuth device authorization endpoints, so the CLI should be able to start a device flow and poll for the resulting access token without opening a browser callback listener.

Impact

Users can run bk auth login --device on a headless or remote machine, authorize from another browser, and have the CLI persist the resulting access and refresh tokens through the same OAuth storage path as browser login. Existing browser login and --token login behavior is preserved.

What Changed

  • Added bk auth login --device.
  • Added OAuth device authorization request and device-code token polling helpers.
  • Reused the existing OAuth persistence path so browser login and device login both resolve the authorized organization, store the access token, store refresh tokens when present, and select the organization in config.
  • Only advertises automatic refresh when refresh-token storage actually succeeds.
  • Rejects incompatible --device --token and --device --org combinations; device flow chooses the organization on the authorization page.
  • Added request-level tests for device authorization, invalid_scope, authorization_pending, and slow_down polling behavior.
  • Added a command-level device-login test that exercises device authorization, token exchange, organization lookup, keyring storage, refresh-token storage, and config selection.
  • Updated the pinned Go toolchain to 1.26.4 and removed unused go-buildkite/v5 module metadata inherited from the rebase so the current tidy and govulncheck CI gates pass.

@lox lox marked this pull request as ready for review June 3, 2026 02:03
@lox lox requested review from a team as code owners June 3, 2026 02:03
@lox lox force-pushed the lox/auth-login-device branch 2 times, most recently from aef7844 to 76200c6 Compare June 3, 2026 02:08
@lox lox force-pushed the lox/auth-login-device branch from 76200c6 to 35d61de Compare June 3, 2026 02:13
Comment thread pkg/oauth/oauth.go
@lox lox merged commit 495db27 into main Jun 3, 2026
3 checks passed
@lox lox deleted the lox/auth-login-device branch June 3, 2026 21:57
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.

2 participants