Expand description
Per-user JWT signing/verification for the web layer.
Tokens are signed with each user’s own RSA key (private key in their per-user
DB, public key in the global users directory). This module wraps the
server key lookups + the token codec into mint/verify helpers the auth
handlers call.
Verification always reads the authoritative public key from the directory —
no public-key cache. A cache would risk accepting tokens signed with a
rotated/revoked key until process restart; correctness wins over saving one
indexed primary-key lookup. The DoS surface of unauthenticated lookups is
bounded by the per-address throttle on the auth routes
(crate::rate_limit), not by caching.
Enums§
Functions§
- mint
- Mints a token of
token_typeforuser_id, signed with that user’s private key.generationis threaded in by the caller rather than re-read here: login already holds it from the password check and refresh from the verified token, so minting costs no extra query. - secure_
cookies - Whether auth cookies should carry the
Secureattribute (sent only over HTTPS). Defaults totrue; setINSECURE_COOKIES=1for local plain-HTTP development. Bearer cookies (access/refresh tokens) must beSecurein production so they can’t leak over a downgraded HTTP request. - verify
- Verifies a token of the EXPECTED type against its owner’s public key.