Merge pull request #10868 from ywk253100/200227_auth

Add "Docker-Distribution-Api-Version" header for the 401 response of registry API
This commit is contained in:
Wang Yan 2020-02-28 11:15:08 +08:00 committed by GitHub
commit 45aac8c597
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -130,6 +130,8 @@ func Middleware() func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
if err := checker.check(req); err != nil {
// the header is needed for "docker manifest" commands: https://github.com/docker/cli/issues/989
rw.Header().Set("Docker-Distribution-Api-Version", "registry/2.0")
serror.SendError(rw, ierror.UnauthorizedError(err).WithMessage(err.Error()))
return
}