JWT (JSON Web Token)
Stateless, self-contained tokens that carry signed claims, no server-side session lookup needed.
A request arrives at one of your twelve services carrying a token. That service has to decide, in under a millisecond, whether the person is who they claim and whether they are an admin.
It could ask a central auth service, which means a network call on every request to every service, and an outage there takes all twelve down.
Or the token could carry the answer itself, signed, so any service checks it with local arithmetic and no network at all.
That is a JWT: a small signed document saying this is user 4812 and they are an admin. It removes the shared bottleneck, and it introduces a problem the industry is still arguing about, which is what happens when you need to take that admin badge away before the token expires.
Lessons
4 in this chapter- Anatomy of a JWTThree base64url segments: a header, a claims payload anyone can read, and a signature.2 min
- Signing and VerificationHS256 shares one secret with every verifier; RS256 keeps the forging power in one place.3 min
- The Revocation ProblemA signature can't be un-signed, so a JWT stays valid until exp no matter what happens.2 min
- JWT Mistakes That Get Exploitedalg none, key confusion, localStorage theft: the exploits are verification steps someone skipped.3 min