{"record":{"id":"a528ff7efa51a819","repo":"diegosouzapw/OmniRoute","slug":"authz-unauthenticated","errorCode":"AUTHZ_UNAUTHENTICATED","errorMessage":"Authentication required","messagePattern":"Authentication required","errorType":"exception","errorClass":"AuthzAssertionError","httpStatus":401,"severity":"error","filePath":"src/server/authz/assertAuth.ts","lineNumber":84,"sourceCode":"    throw new AuthzAssertionError(\n      \"AUTHZ_NOT_INITIALIZED\",\n      \"Request did not pass through the authz middleware\",\n      500\n    );\n  }\n\n  if (actualClass !== expected) {\n    throw new AuthzAssertionError(\n      \"AUTHZ_ROUTE_CLASS_MISMATCH\",\n      `Expected ${expected} but got ${actualClass}`,\n      500\n    );\n  }\n\n  const subject = readSubjectFromHeaders(headers);\n\n  if (expected !== \"PUBLIC\" && subject.kind === \"anonymous\") {\n    throw new AuthzAssertionError(\"AUTHZ_UNAUTHENTICATED\", \"Authentication required\", 401);\n  }\n\n  return subject;\n}\n","sourceCodeStart":66,"sourceCodeEnd":89,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/server/authz/assertAuth.ts#L66-L89","documentation":"Sentinel 401 assertion thrown by assertAuth() when the request did not pass through the authz middleware's authenticated class but a non-PUBLIC route class was expected: the subject read from headers is anonymous. It means a route declared itself protected but no valid credential (API key/JWT) was presented.","triggerScenarios":"Thrown at src/server/authz/assertAuth.ts:84 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Client must send valid credentials (Authorization header / API key) for the protected route","Verify the authz middleware actually ran and classified the route correctly","Check that extractApiKey/isValidApiKey ran before the assertion and the header is not stripped by a proxy","For intentionally public routes, declare the route class as PUBLIC instead of expecting auth"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}