docker
transport does not respect per-repo authn challenges if /v2/ does not return 401
#2754
Labels
kind/feature
A request for, or a PR adding, new functionality
As far as I can tell, Skopeo determines whether authentication is required for a registry based solely on the
GET /v2/
response via the presence of aWWW-Authenticate
challenge in a401 Unauthorized
response. If this initial "ping" endpoint allows unauthenticated access, Skopeo assumes the entire registry does not require authentication. However, this behavior fails in cases where a registry implements per-repository access controls, where the registry itself, and some repositories, may allow unauthenticated access, while others require authentication. This is common, especially for multi-tenant registries.This behavior deviates from the Docker CLI and Oras, both which correctly handle per-repository authentication and authorization. Specifically, Docker respects
WWW-Authenticate
challenges for individual repository endpoints, e.g./v2/<repo>/manifests/<tag>
, even if theGET /v2/
"ping" endpoint previously succeeded without an authentication challenge.Steps to reproduce
Set up a registry with the following behavior:
GET /v2/
: returns200 OK
without requiring authentication.GET /v2/foo/manifests/latest
: requires authentication and responds with401 Unauthorized
and aWWW-Authenticate: Basic
challenge.GET /v2/bar/manifests/latest
: allows unauthenticated access.Attempt to list tags for the repository that requires authentication using Skopeo:
Observe that Skopeo does not send or resend the request with an
Authorization
header, even after receiving a401 Unauthorized
response for/v2/foo/tags/list
, even though a challenge was received and credentials were explicitly provided via--creds
.Compare this behavior to Docker:
Docker correctly resends the request with credentials after receiving the
401 Unauthorized
response for/v2/foo/manifests/latest
.Compare this behavior to Oras:
Oras correctly resends the request with credentials after receiving the
401 Unauthorized
response for/v2/foo/manifests/latest
.Expected behavior
Skopeo should respect
WWW-Authenticate
challenges for individual repository endpoints when and if they occur.Actual behavior
Skopeo assumes that the registry does not require authentication if the initial
GET /v2/
"ping" endpoint responds with200 OK
, and does not attempt to resend the failed request even thought an authentication challenge is present in the response.Debug logs
Related issues
Relevant comment in #195
Emphasis mine. Fixed link reference is here.
The text was updated successfully, but these errors were encountered: