Merge pull request #46631 from rumpl/c8d-no-basic-auth

Return no basic auth creds error when needed
This commit is contained in:
Sebastiaan van Stijn 2023-10-13 13:03:26 +02:00 committed by GitHub
commit 6c1c76d02a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,6 +11,7 @@ import (
"github.com/containerd/containerd/remotes/docker"
"github.com/containerd/containerd/version"
"github.com/containerd/log"
"github.com/docker/distribution/registry/client/auth"
registrytypes "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/dockerversion"
"github.com/docker/docker/pkg/useragent"
@ -75,11 +76,15 @@ func authorizerFromAuthConfig(authConfig registrytypes.AuthConfig) docker.Author
"host": host,
"cfgHost": cfgHost,
}).Warn("Host doesn't match")
return "", "", nil
return "", "", auth.ErrNoBasicAuthCredentials
}
if authConfig.IdentityToken != "" {
return "", authConfig.IdentityToken, nil
}
if authConfig.Username == "" && authConfig.Password == "" {
return "", "", auth.ErrNoBasicAuthCredentials
}
return authConfig.Username, authConfig.Password, nil
}))
}