Reading — step 1 of 5
Read
~1 min readProduction Concerns
Putting It All Together
You've built every layer:
| Layer | Lesson |
|---|---|
| Base64url | 1 |
| Header + payload | 2 |
| HS256 signing | 3 |
| RS256 verify | 4 |
| Claim validation | 5 |
| Key rotation | 6 |
| Attack detection | 7 |
Production JWT library checklist:
- Pin algorithms per-key (don't trust header
alg) - Constant-time signature comparison
- 32+ byte random keys for HS256
- Short
exp(5-60 min); use refresh tokens for longer sessions - Validate
iss,aud,nbf,exp, optionalnbf/leeway - Support JWKS endpoints with
kidfor key rotation - Cache JWKS responses (e.g. 1 hour) but refresh on unknown
kid - Don't put secrets in payload — anyone can read it
- Don't log full JWTs (token bearer)
What we glossed over:
- JWE (JSON Web Encryption): encrypted payload. RFC 7516. Used when payload IS sensitive.
- JWS detached payload: signature is separate from data. Useful for streaming.
- EdDSA / Ed25519: modern signing — faster and smaller than RSA, deterministic, no nonce-reuse footguns.
- PASETO / Biscuit: alternatives designed to fix JWT's footguns by removing dangerous features.
You now understand JWT well enough to use it (or argue against it). Many shops are moving to opaque tokens + Redis sessions because JWT's revocation story is ugly.
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…