Skip to main content

One post tagged with "jwt"

View All Tags

JWKS explained: rotation, caching, validating tokens

· 14 min read
Jeff Patzer
Phase Two

A JWKS — JSON Web Key Set — is a JSON document containing a list of public keys, each encoded as a JWK (JSON Web Key). Its purpose is to let anyone verifying a signed token fetch the right public key over HTTP instead of having it configured by hand. The token names the key it was signed with in its kid header; the verifier looks that kid up in the set.

That is the whole idea, and it buys one specific thing: the signer can change keys without anyone who verifies its tokens changing configuration. Everything else about JWKS — the field names, the caching, the rotation ordering — follows from that.

This post covers what is actually in a JWK, where the JWKS URL comes from, what Keycloak publishes and what it deliberately does not, and the two directions the traffic flows in. Every number and every error string below came from a real run.

Tested against

Keycloak 26.7.4 in a container, plus Python 3.12 with cryptography 46 for the key arithmetic. JWK field definitions are from RFC 7517 and RFC 7518.