Skip to content

cli/login: device-code login for registries that advertise it - #7436

Open
BRAVO68WEB wants to merge 1 commit into
docker:masterfrom
BRAVO68WEB:7435-registry-device-login
Open

BRAVO68WEB wants to merge 1 commit into
docker:masterfrom
BRAVO68WEB:7435-registry-device-login

Conversation

@BRAVO68WEB

Copy link
Copy Markdown

Closes #7435

What

docker login registry.example.com, with no username or password, uses a browser device-code flow when the registry advertises one. Docker Hub's own login is unchanged. A registry that does not advertise the flow still asks for a username and password. -u and --password-stdin still skip the browser.

How

GET /v2/ is read for a bearer challenge:

WWW-Authenticate: Bearer realm="https://registry.example.com/token",service="registry",device_authorization_endpoint="https://registry.example.com/oauth/device/code"

token_endpoint overrides realm when the poll URL is not the realm. The CLI then follows RFC 8628: it posts client_id=docker, prints the user code and verification URL, opens the browser on Enter, and polls. A successful poll is JSON:

{"username":"alice","secret":"..."}

identity_token may be sent instead of secret. The result is checked with the existing registry login and stored in the usual credential store. An https registry cannot point the device or token URL at http.

The Hub OAuthManager path is not used. That client mints a Hub personal access token and is still limited to Docker Hub.

How to verify

go test ./internal/registry/ ./cli/command/registry/

The registry tests cover discovery, the https rejection, a pending poll that then succeeds, and a refused sign-in.

Docker Hub already signs in through a browser. A self-hosted registry
can now offer the same flow by advertising a device authorization
endpoint on the GET /v2/ bearer challenge. Password login stays the
fallback, and the Hub login path is unchanged.

Closes docker#7435

Signed-off-by: Jyotirmoy Bandyopadhayaya <[email protected]>
@BRAVO68WEB
BRAVO68WEB requested review from a team and thaJeztah as code owners October 25, 2026 01:15
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.

Allow device-code docker login for registries that advertise it

1 participant