Use auth.required() on routes that require an authenticated actor and
auth.optional() where handlers can use auth when present. The returned
route hooks enrich handler ctx; business authorization still belongs in
feature policies or use cases.
Declare a headers schema when credentials live in request headers. The
hook validates the raw lowercase header record itself, so resolve receives
typed headers without contract casts and a required() hook rejects
missing or malformed credentials with a framework-owned 401.
Create route-scoped authentication hooks.
The outer call binds the app context; the inner call takes auth options and infers the added context from
resolve:Use
auth.required()on routes that require an authenticated actor andauth.optional()where handlers can use auth when present. The returned route hooks enrich handlerctx; business authorization still belongs in feature policies or use cases.Declare a
headersschema when credentials live in request headers. The hook validates the raw lowercase header record itself, soresolvereceives typed headers without contract casts and arequired()hook rejects missing or malformed credentials with a framework-owned 401.