Repository navigation
registry: authorize with Secrets Engine before reading the Docker Desktop session - #14542
Merged
Merged
Conversation
4 of 5 tasks
Benehiko
force-pushed
the
registry/desktop-authorize
branch
from
November 23, 2026 08:15
f78f847 to
bb8956d
Compare
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
Assessment: 🟡 NEEDS ATTENTION
Lower-confidence findings (not posted inline)
- [low]
internal/registry/desktop.go:171 —s.authorizednot reset tofalseafter re-authorization fails (confidence: not verified, low severity) - [low]
internal/registry/desktop_test.go:596 —TestDesktopAuthProvider_FallsBackWhenNotAuthorizeddoes not assertpingCalls, leaving retry-on-denied behaviour partially untested (confidence: not verified, low severity)
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Benehiko
force-pushed
the
registry/desktop-authorize
branch
2 times, most recently
from
November 25, 2026 12:22
e0d0f44 to
bd3e8b7
Compare
Member
Author
|
On the two lower-confidence findings from the docker-agent review, both addressed in cc2783f: authorize() now clears s.authorized and s.authorizedUntil before asking again once the decision has expired (it was already re-checked through authorizedUntil, so this only makes the state explicit), and TestDesktopAuthProvider_FallsBackWhenNotAuthorized now asserts pingCalls. |
…ktop session Docker Desktop can prompt the user before it gives a process access to a realm, and reading the default Docker Hub session reads from two realms, docker/auth/metadata/hub/** and docker/auth/hub/**. The 5 second lookup timeout expired before the user could answer, so the lookup fell back to the Docker CLI credentials. Call Authorize once on docker/auth/**, which covers the production and staging realms, with a one minute timeout, and keep the decision until the expiry Docker Desktop returns. The session reads keep their 5 second timeout. A denied or unanswered authorization falls back to the Docker CLI credentials like any other failed lookup. Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
…gine answers Authorize has a one minute timeout, so the user can answer the Docker Desktop prompt. An engine that accepts the connection but never answers looked the same, and delayed the first Docker Hub lookup by a minute. Ask the engine for its version first, within the 5 second lookup timeout, and only then call Authorize. The secrets engine API has no way to say that it is waiting for the user, but the version request is not gated by a prompt: it answered in about 10 ms from a new process. An engine that does not answer now falls back after 5 seconds, as before. A version request that times out returned only the RPC deadline error, which was logged as a warning. Report it as a ConnectError with ReasonTimeout and the socket path, so it reads as the secrets engine not responding and is logged at debug level, like a socket that is missing or refuses the connection. A timeout on the prompt or on the session reads is still logged as a warning. Clear an expired decision before authorizing again, so a failed authorization does not leave the old one in place. Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
The version request that comes before Authorize is not gated by a prompt and answered in about 10 ms from Docker Desktop, so it does not need the 5 second lookup timeout. With 1 second, an engine that accepts the connection but does not answer falls back to the Docker CLI credentials after 1 second instead of 5. The session reads keep 5 seconds and Authorize keeps 1 minute. Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
Benehiko
force-pushed
the
registry/desktop-authorize
branch
from
December 3, 2026 10:10
bd3e8b7 to
c5d33a9
Compare
Benehiko
marked this pull request as ready for review
December 3, 2026 11:27
docker-agent
reviewed
Dec 3, 2026
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
Assessment: 🟡 NEEDS ATTENTION
3 of 16 tasks
ndeloof
approved these changes
Dec 4, 2026
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.
Note
Builds on #14541, which bumped
github.com/docker/secrets-engine/clientto v1.0.0 and is now merged. Tested against Docker Desktop on macOS with a binary that is not signed by Docker (see Docker Desktop test). Not yet tested with a Docker-signed build, on Linux or Windows, or with the E2E suite.What this PR does
These changes are for Compose binaries that are not signed by Docker: Compose built from source, for local development, and the binaries that run the tests. Docker Desktop prompts the user before it gives such a binary access to the Docker Hub session. Compose binaries signed by Docker should get no prompt: for them Compose makes a version request and an
Authorizecall before the first session read, and Docker Desktop answersAuthorizewithout asking the user.Authorizeondocker/auth/**before reading the Docker Desktop session, so Docker Desktop prompts at most once per process, and gives the user up to 1 minute to answer that prompt. Before this, every lookup from a binary not signed by Docker timed out after 5 seconds while the prompt was still open, and fell back to the Docker CLI credentials.Authorizethat time only once the engine has answered a version request within 1 second, so an engine that hangs falls back after 1 second. Builds signed by Docker get no prompt, so for themAuthorizeanswers without waiting on the user.Related issue
No Compose issue. Builds on #14541 (merged).
Changes made
registry: authorize with Secrets Engine before reading the Docker Desktop session:desktopSessioncallsAuthorize(docker/auth/**). That pattern coversdocker/auth/hub/**,docker/auth/metadata/hub/**, and theirhub-stagingcounterparts, so one decision serves both the production and the staging session.Authorizegets a 1 minute timeout (desktopAuthorizeTimeout), to leave time for the prompt. The session reads keep the 5 seconddesktopLookupTimeout, now applied through their contexts only: the client-wideWithTimeout(5s)is removed, since it would cut the prompt short.secrets.ErrAccessDeniedand anAuthorizeerror is wrapped; both fall back to the Docker CLI credentials and are not retried forretryInterval, like any other failed lookup.registry: wait for the Docker Desktop prompt only when the secrets engine answersandregistry: give the secrets engine version check 1 second:Authorizeis a unary RPC andDecisionis onlyDENYorALLOW.Authorize,desktopSessioncallsVersion(desktopHub.Ping) within the 1 seconddesktopPingTimeout. Only if it answers doesAuthorizeget the 1 minutedesktopAuthorizeTimeout.Versionis not gated by a prompt: it answered in 9.6 ms from a new process, against secrets engine v0.5.0 in Docker Desktop.ConnectErroror a timeout, falls back without callingAuthorizeor reading the session.Versiontimeout is reported as aseclient.ConnectErrorwithReasonTimeoutand the socket path (secrets engine did not respond in time at <socket>), so it is logged at debug level like a missing socket or a refused connection, instead of as a warning with only the RPC deadline error. A timeout on the prompt or on the session reads is still a warning.VersionAuthorize, afterVersionansweredTests: the pattern sent is
docker/auth/**and contains the four Hub realms;PingcallsVersion, reports a timeout as the engine not responding, and keeps other errors as they are; authorization and the ping happen once across session refetches; authorization happens again after the decision expires; a denial, an access-denied error, or an unanswered prompt falls back without reading the session or pinging again; a failed ping falls back without authorizing; the ping gets at most 1 second andAuthorizethe longer timeout; the production timeouts are 1 s, 5 s, and 1 min.Docker Desktop test
A throwaway program, not part of this PR, called
registry.NewDesktopAuthProvideragainst the running Docker Desktop on macOS (darwin/arm64), with a fallback that marks the Docker CLI credentials. It looked updocker.io,index.docker.io,registry-1.docker.io,https://index.docker.io/v1/,dhi.io,registry-1-stage.docker.io, andghcr.io, twice each. Tokens were never printed. The binary is built bygo run, so it is not signed by Docker and Docker Desktop prompts for it.dhi.ioServerAddresshttps://dhi.ioregistry-1-stage.docker.ioghcr.ioAgainst the real secrets engine client, without Docker Desktop, after the change to how a
Versiontimeout is reported:secrets engine did not respond in time at <socket>), Docker CLI credentials;Authorizenever calledsecrets engine is not running at <socket>), Docker CLI credentialssecrets engine is not running at <socket>), Docker CLI credentialsAuthorizereturned an expiry about 11 hours ahead.Testing done
internal/registry, with-racemake e2e-composeormake e2e-compose-standalonegolangci-lint run ./internal/registry/...(not the fullmake lint)golangci-lint fmt ./internal/registry/...Open items
desktopAuthorizeTimeout? It applies only after the engine has answered a version request, and builds signed by Docker get no prompt, but an engine that answersVersionand then hangs onAuthorizewould still delay the first Docker Hub lookup by up to 1 minute.Authorizedoes, after at most 1 minute. A second Ctrl+C exits at once.AuthProvider.GetAuthConfigtakes no context because it follows the Docker CLI'sconfigfile.GetAuthConfig; passing the caller's context needs to start in the Docker CLI and be picked up here, not in this PR.docker/auth/**the realm to authorize? It also coversdocker/auth/registry/**, which Compose does not read.Authorizeto report that it is waiting for the user, such as a streamed status or a pending decision, would let clients wait for the prompt and fail fast otherwise, instead of relying onVersion.AI tool used (if applicable)
AI Tool: alki, an AI coding agent, running Claude Opus 5.5. It wrote the code changes and the tests, ran the tests and the Docker Desktop test, and wrote this description.