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 addressed by rate-limiting the auth endpoints, not by caching.
Enums§
Functions§
- mint
- Mints a token of
token_typeforuser_id, signed with that user’s private key. - 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.