diegosouzapw/OmniRoute · error · AuthzAssertionError
AUTHZ_UNAUTHENTICATED
AUTHZ_UNAUTHENTICATED
Error message
Authentication required
What it means
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.
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/server/authz/assertAuth.ts:84 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 diegosouzapw/OmniRoute@a179ffed5b (2026-08-25).
Data as JSON: /api/errors/a528ff7efa51a819.
Report an issue: GitHub.
Appendix: source
Thrown at src/server/authz/assertAuth.ts:84
throw new AuthzAssertionError(
"AUTHZ_NOT_INITIALIZED",
"Request did not pass through the authz middleware",
500
);
}
if (actualClass !== expected) {
throw new AuthzAssertionError(
"AUTHZ_ROUTE_CLASS_MISMATCH",
`Expected ${expected} but got ${actualClass}`,
500
);
}
const subject = readSubjectFromHeaders(headers);
if (expected !== "PUBLIC" && subject.kind === "anonymous") {
throw new AuthzAssertionError("AUTHZ_UNAUTHENTICATED", "Authentication required", 401);
}
return subject;
}
View on GitHub (pinned to a179ffed5b)