Repository navigation
cli/login: device-code login for registries that advertise it - #7436
Open
BRAVO68WEB wants to merge 1 commit into
Open
BRAVO68WEB wants to merge 1 commit into
BRAVO68WEB wants to merge 1 commit into
Conversation
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]>
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.
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.-uand--password-stdinstill 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_endpointoverridesrealmwhen the poll URL is not the realm. The CLI then follows RFC 8628: it postsclient_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_tokenmay be sent instead ofsecret. The result is checked with the existing registry login and stored in the usual credential store. Anhttpsregistry cannot point the device or token URL athttp.The Hub
OAuthManagerpath 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.