diff --git a/pkg/api/routes.go b/pkg/api/routes.go index 4d3d9fc3e4..182e11c161 100644 --- a/pkg/api/routes.go +++ b/pkg/api/routes.go @@ -140,13 +140,11 @@ func (rh *RouteHandler) CheckVersionSupport(response http.ResponseWriter, reques response.Header().Set(constants.DistAPIVersion, "registry/2.0") // NOTE: compatibility workaround - return this header in "allowed-read" mode to allow for clients to // work correctly - if checkAnonymousPolicyExists(rh.c.Config.AccessControl) { - if rh.c.Config.HTTP.Auth != nil { - if rh.c.Config.HTTP.Auth.Bearer != nil { - response.Header().Set("WWW-Authenticate", fmt.Sprintf("bearer realm=%s", rh.c.Config.HTTP.Auth.Bearer.Realm)) - } else { - response.Header().Set("WWW-Authenticate", fmt.Sprintf("basic realm=%s", rh.c.Config.HTTP.Realm)) - } + if rh.c.Config.HTTP.Auth != nil { + if rh.c.Config.HTTP.Auth.Bearer != nil { + response.Header().Set("WWW-Authenticate", fmt.Sprintf("bearer realm=%s", rh.c.Config.HTTP.Auth.Bearer.Realm)) + } else { + response.Header().Set("WWW-Authenticate", fmt.Sprintf("basic realm=%s", rh.c.Config.HTTP.Realm)) } }