{"record":{"id":"36a2f68a7397627a","repo":"caddyserver/caddy","slug":"not-authenticated","errorCode":null,"errorMessage":"not authenticated","messagePattern":"not authenticated","errorType":"http","errorClass":null,"httpStatus":401,"severity":"error","filePath":"modules/caddyhttp/caddyauth/caddyauth.go","lineNumber":158,"sourceCode":"\t\t}\n\t\t// When isolating, no failed provider's response reached the real\n\t\t// writer, so apply one provider's challenge headers (e.g. a\n\t\t// WWW-Authenticate, or a Location); a redirecting provider takes\n\t\t// precedence and is sent as a full response. A single provider already\n\t\t// wrote its challenge directly to the real writer. Either way, fall\n\t\t// through to the auth error so handle_errors runs and a challenge that\n\t\t// set only headers (like basic auth) still returns 401, not 200.\n\t\tif isolate {\n\t\t\tif replay := pickReplay(failed); replay != nil {\n\t\t\t\tmaps.Copy(w.Header(), replay.header)\n\t\t\t\tif replay.statusCode >= 300 && replay.statusCode < 400 {\n\t\t\t\t\tw.WriteHeader(replay.statusCode)\n\t\t\t\t\t_, _ = w.Write(replay.buf.Bytes())\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn caddyhttp.Error(http.StatusUnauthorized, fmt.Errorf(\"not authenticated\"))\n\t}\n\n\t// When isolating, the winning provider wrote to its buffer; copy the\n\t// headers it set (e.g. a Set-Cookie establishing a new session) onto the\n\t// real writer. Its status/body are NOT replayed: the request is\n\t// authenticated and continues down the handler chain, which produces the\n\t// actual response. (A single provider already wrote its headers directly.)\n\tif winner != nil {\n\t\tmaps.Copy(w.Header(), winner.header)\n\t}\n\n\tsetAuthUserPlaceholders(repl, \"http.auth.user\", user)\n\n\treturn next.ServeHTTP(w, r)\n}\n\n// pickReplay chooses which failed provider's buffered response to send when\n// no provider authenticated: a redirect (3xx) wins, otherwise the first","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/modules/caddyhttp/caddyauth/caddyauth.go#L140-L176","documentation":"Error \"not authenticated\" thrown in caddyserver/caddy.","triggerScenarios":"Thrown at modules/caddyhttp/caddyauth/caddyauth.go:158 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Send valid credentials with the request (e.g. correct Authorization header for basic auth).","Verify the username and password match a configured account."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}