goharbor/harbor · error · *errors.Error
UNAUTHORIZED
UNAUTHORIZED
Error message
unauthorized
What it means
Error "unauthorized" thrown in goharbor/harbor.
Source
Thrown at src/server/middleware/v2auth/auth.go:57
authHeader = "Authorization"
)
type reqChecker struct {
ctl project.Controller
}
func (rc *reqChecker) check(req *http.Request) (string, error) {
securityCtx, ok := security.FromContext(req.Context())
if !ok {
return "", fmt.Errorf("the security context got from request is nil")
}
al := accessList(req)
if len(al) == 0 {
return "", fmt.Errorf("un-recognized request: %s %s", req.Method, req.URL.Path)
}
for _, a := range al {
if a.target == login && !securityCtx.IsAuthenticated() {
return getChallenge(req, al), errors.New("unauthorized")
}
if a.target == catalog {
resource := system.NewNamespace().Resource(rbac.ResourceCatalog)
if !securityCtx.Can(req.Context(), rbac.ActionRead, resource) {
return getChallenge(req, al), fmt.Errorf("unauthorized to list catalog")
}
}
if a.target == repository && req.Header.Get(authHeader) == "" &&
(req.Method == http.MethodHead || req.Method == http.MethodGet) { // make sure 401 is returned for CLI HEAD, see #11271
return getChallenge(req, al), fmt.Errorf("authorize header needed to send HEAD to repository")
} else if a.target == repository {
pn := strings.Split(a.name, "/")[0]
pid, err := rc.projectID(req.Context(), pn)
if err != nil {
return "", err
}
resource := rbac_project.NewNamespace(pid).Resource(rbac.ResourceRepository)
if !securityCtx.Can(req.Context(), a.action, resource) {View on GitHub (pinned to 7b2fd08cc5)
When it happens
Trigger: Thrown at src/server/middleware/v2auth/auth.go:57 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16).
Data as JSON: /api/errors/a862a3d7900779e0.
Report an issue: GitHub.