credhelper: add static-Bearer mode#129
Merged
Merged
Conversation
When a docker-credential helper returns Username "<static_bearer>", install the Secret as a literal "Authorization: Bearer <Secret>" header on the RegistryHost and skip the challenge-response auth flow. Used by callers whose registry accepts a bearer token directly rather than via an OAuth2 realm exchange (e.g. the Datadog Terrapin Forwarder, which authenticates the calling sandbox via a pre-minted identity JWT). Adds a unit test covering the new sentinel path. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
guyboltonking
approved these changes
May 14, 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.
Summary
Add a static-Bearer authentication mode to
credhelper.RegistryHostsFromDockerConfig. When a docker-credential helper returnsUsername == "<static_bearer>", the helper's Secret is installed as a literalAuthorization: Bearer <Secret>header on theRegistryHost, and the docker challenge-response auth flow is skipped entirely.Motivation
Some registries authenticate the caller via a pre-minted bearer token rather than an OAuth2 realm exchange. Concretely: Datadog's Terrapin Forwarder accepts the calling sandbox's identity JWT directly as a bearer, with no token endpoint to exchange against. Today,
RegistryHostsFromDockerConfigalways wires up adocker.NewDockerAuthorizerthat runs the WWW-Authenticate challenge flow — either Basic-auth or OAuth2 token exchange — neither of which matches "send this token verbatim."The new path mirrors go-containerregistry's
"<token>"username convention, but tighter:"<token>"still goes through an OAuth2 refresh_token exchange against the challenge realm."<static_bearer>"skips that and just sets the header.Behavior
Username: "<static_bearer>", the host is configured with:Header = http.Header{"Authorization": []string{"Bearer <Secret>"}}— applied to every request via containerd'sRegistryHost.Headermerge (remotes/docker/resolver.go).Authorizer = nil— challenge-response auth flow disabled.Test plan
TestRegistryHostsStaticBearerSentinelcovers the sentinel path: confirms theAuthorization: Bearer …header is installed and the Authorizer is nil.bazel run //:bootstrap && bazel test //...— 6/6 pass on this branch (buildifier_test,docs:update_test,go/cmd/ocitool:go_default_test,go/pkg/credhelper:credhelper_test,go/pkg/deb2layer:go_default_test,go/pkg/ociutil:go_default_test).ocitooland pulling a multi-arch image (registry.ddbuild.io/images/compute-toolbox@sha256:d45510ad…) through our forwarder proxy from inside a sandbox: manifest list → platform manifests → config + layer blobs all 200 OK. Without the patch the same flow gets401 Unauthorizedbecause the forwarder's challenge isn't an OAuth2 token endpoint.🤖 Generated with Claude Code