Skip to content

cli/command: look up registry credentials through internal/registryauth - #7572

Merged
thaJeztah merged 1 commit into
docker:masterfrom
Benehiko:registryauth-encoded-auth
Dec 4, 2026
Merged

thaJeztah merged 1 commit into
docker:masterfrom
Benehiko:registryauth-encoded-auth

Conversation

@Benehiko

@Benehiko Benehiko commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Note

This PR was created with alki, an AI coding agent, running Claude Opus 5.5: the code, the tests, and this description.

Summary

Move the lookup of the encoded registry credentials (the X-Registry-Auth header) for an image into a new internal/registryauth package, and use it everywhere commands send credentials to the daemon: docker pull, push, run, create, plugin install, upgrade and push, service create and update, and stack deploy.

  • registryauth.Encoded(ctx, cfg, image) takes any AuthConfigProvider (anything with GetAuthConfig(registryHostname), such as *configfile.ConfigFile), and carries over the GoDoc of command.RetrieveAuthTokenFromImage.
  • command.RetrieveAuthTokenFromImage is kept, since other projects import it, and is now a wrapper around registryauth.Encoded. Its tests moved to internal/registryauth unchanged.
  • Encoded takes the context of the command. It is not used yet: WIP: use the secrets engine session for Docker Hub and dhi.io credentials #7431 uses it so that a credential lookup that waits on another process (the secrets engine authorization prompt) is canceled with the command.
  • No behaviour change: credentials still come from DOCKER_AUTH_CONFIG, the credential store, credential helpers, and the configuration file.

Release notes (optional)

@codecov-commenter

codecov-commenter commented Dec 4, 2026 •

Copy link
Copy Markdown

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

@Benehiko
Benehiko marked this pull request as ready for review December 4, 2026 11:02
@Benehiko
Benehiko requested review from a team and silvin-lubecki as code owners December 4, 2026 11:03

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

Comment thread internal/registryauth/registryauth.go Resolved
@Benehiko
Benehiko force-pushed the registryauth-encoded-auth branch 4 times, most recently from e5940f0 to d7b3ab8 Compare December 4, 2026 13:28
@Benehiko
Benehiko requested a review from thaJeztah December 4, 2026 13:43

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

Comment thread internal/registryauth/registryauth.go Resolved
Comment thread internal/registryauth/registryauth.go Resolved
@Benehiko
Benehiko force-pushed the registryauth-encoded-auth branch from d7b3ab8 to 91e08a0 Compare December 4, 2026 14:41
Move the lookup of the encoded registry credentials for an image into the new internal/registryauth package, and use it where commands send credentials to the daemon: docker pull, push, run, create, plugin install, upgrade and push, service create and update, and stack deploy. command.RetrieveAuthTokenFromImage is kept for compatibility, as a wrapper around registryauth.Encoded, and its tests move to the new package.

registryauth.Encoded takes the context of the command, so that a lookup that needs to wait, such as one that asks another process for credentials, can be canceled with the command. It takes any AuthConfigProvider instead of a configfile.ConfigFile. The credentials do not change: they come from DOCKER_AUTH_CONFIG, the credential store, credential helpers, and the configuration file.

Document how the daemon uses the Password, Auth, IdentityToken, and RegistryToken fields of types.AuthConfig, which answers the TODO that asked whether the encoded credentials should include them.

Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
@Benehiko
Benehiko force-pushed the registryauth-encoded-auth branch from 91e08a0 to 0dcf19d Compare December 4, 2026 14:47
@Benehiko
Benehiko requested a review from thaJeztah December 4, 2026 15:00

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

@thaJeztah thaJeztah added this to the 29.11.0 milestone Dec 4, 2026
@thaJeztah thaJeztah added kind/refactor PR's that refactor, or clean-up code area/authentication labels Dec 4, 2026

@thaJeztah thaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thx!

@thaJeztah
thaJeztah merged commit 526f63f into docker:master Dec 4, 2026
108 of 109 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/authentication kind/refactor PR's that refactor, or clean-up code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants