Quick revision
The short answer
Only the identity provider signs user access tokens, using asymmetric algorithms such as RS256 or ES256 that are fixed in each service's configuration. Keys are published through a JWKS endpoint with a kid on every key, services cache them for a bounded time and refetch when they see an unknown kid, and rotation overlaps are longer than both the cache lifetime and the token lifetime. The platform starter ships this decoder configuration, and rotation is tested regularly rather than trusted.
What to remember
In this answer, we set a signing standard for 100 services. Only the identity provider signs user tokens, using RS256 or ES256 fixed in each service's configuration. Keys are published through JWKS with a kid, cached for minutes and refetched on an unknown kid. Rotation publishes the new key before using it and keeps the old one longer than the cache and token lifetimes. The platform starter delivers all of it, and rotation drills prove it works.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Only the identity provider signs user access tokens, using asymmetric algorithms such as RS256 or ES256 that are fixed in each service's configuration. Keys are published through a JWKS endpoint with a kid on every key, services cache them for a bounded time and refetch when they see an unknown kid, and rotation overlaps are longer than both the cache lifetime and the token lifetime. The platform starter ships this decoder configuration, and rotation is tested regularly rather than trusted.
Why this question is asked
With five services, every team can configure JWT validation by hand and someone will notice a mistake. With 100 services, that does not hold: one team will accept HS256, another will cache keys forever, and a third will mint its own tokens for convenience. Interviewers ask this design question at senior level because the answer is less about cryptography and more about making the safe choice the default one. In this answer, we will decide who may sign, which algorithms are allowed, how keys are published and cached, how fast rotation must take effect and why, and how the standard reaches 100 teams without each of them reading it.
1A Quick Recap of the Moving Parts
A signed JWT carries a header with alg (the signing algorithm) and kid (the key id, a label that tells the verifier which key was used). The verifier looks up the public key for that kid and checks the signature. A JWKS (JSON Web Key Set) is a JSON document, usually served at a well-known URL by the identity provider, that lists the current public keys with their kids.
Key rotation means replacing the signing key with a new one on a schedule, or immediately after a suspected compromise. Rotation is easy for the signer and hard for verifiers, because every verifier has a cached copy of the old key set. Most of this standard is about making that cache behave.
2Who May Sign Tokens
The first rule is that only the identity provider signs user access tokens. A service that needs to call another service on behalf of a user forwards the user's token or exchanges it at the identity provider for a new one (OAuth 2.0 token exchange). A service that calls on its own behalf gets a client-credentials token from the same provider. No service holds a private key that can mint user tokens.
The reason is containment. If 100 services can sign, a breach of any one of them lets the attacker impersonate any user to all the others, and we have 100 private keys to rotate. With one signer, there is one key to protect, one audit log of issued tokens and one place to rotate. Services may still sign other things, such as webhooks to partners, but those use separate keys and are never accepted as user access tokens.
3Which Algorithms, and Why Asymmetric Only
The standard allows asymmetric algorithms only, for example RS256 (RSA with SHA-256) or ES256 (ECDSA on the P-256 curve), and each service fixes the allowed list in configuration. HS256 is not allowed for access tokens, because a shared secret must be known by every verifier, which means every verifier could sign. With asymmetric keys, verifiers only hold the public key, which is harmless to leak.
Fixing the list in configuration matters as much as the choice itself. A verifier that accepts whatever the token header says is open to alg none and algorithm-confusion attacks. ES256 gives smaller tokens and faster signing; RS256 has the widest library support. Either is fine; picking one company-wide default keeps the configuration simple.
| Area | Rule | Why |
|---|---|---|
| Signer | Identity provider only | One key to protect and rotate |
| Algorithms | RS256 or ES256, fixed per service | Verifiers cannot sign; no alg none |
| Key publication | JWKS with kid on every key | Verifiers pick the right key |
| Key cache | Refresh every 5 to 15 min, refetch on unknown kid | New keys work within seconds |
| Overlap | Old key published longer than cache + token lifetime | No valid token is rejected |
| Claims | iss, aud, exp always validated | Tokens for other services fail |
| Delivery | Decoder in the platform starter | Teams get it by default |
4Publishing and Caching Keys
The identity provider publishes its public keys at a JWKS endpoint, and every key carries a kid. Each token header names its kid, so the verifier knows which key to use without trying them all.
Services cache the key set, because fetching it for every request would put the identity provider on the critical path of every call. But the cache must be bounded: we refresh it every few minutes, and if a token arrives with a kid the cache does not know, the verifier refetches the set immediately (with a rate limit, so a flood of tokens with random kids cannot turn into a flood of fetches). Nimbus, the library behind Spring Security's NimbusJwtDecoder, follows this pattern when the decoder is built with a JWK Set URI. Check the cache and refresh settings for your version.
Notice that a service only needs to supply its own audience. Everything else is the platform's decision.
5How Fast Rotation Must Take Effect
Planned rotation follows a fixed sequence. The identity provider publishes the new public key in the JWKS first, without signing with it. After every cache has had time to pick it up, it starts signing new tokens with the new key. The old key stays published until every token signed with it has expired, and only then is it removed.
The numbers make the overlap concrete. If caches refresh every 10 minutes and access tokens live 15 minutes, the new key must be published at least 10 minutes before signing starts, and the old key must stay at least 15 minutes (plus clock skew) after signing stops. In practice we use generous overlaps, such as a day on each side, for planned monthly or quarterly rotation. For emergency rotation the unknown-kid refetch is what saves us: services pick up a new key on the first token that uses it, within seconds rather than at the next scheduled refresh.
- Publish new key in JWKSNot used for signing yet
- Wait longer than the cache refreshEvery service now knows the new kid
- Start signing with the new keyNew tokens carry the new kid
- Wait longer than the token lifetimeOld tokens have all expired
- Remove the old key from JWKSRotation complete
5 steps in order. Play them, or step through them one at a time.
6Delivering the Standard to 100 Teams
A document alone will not hold across 100 services. The platform team ships a Spring Boot starter whose auto-configuration builds the JwtDecoder with the allowed algorithms, issuer, cache behaviour and claim validators, so a service that adds the dependency is compliant by default. Teams can tighten the configuration but not loosen it without a documented exception.
Then we test it. A rotation drill in staging every month, and a planned rotation in production every quarter, shows whether any service caches keys too long or pins a single key. A contract test in the starter checks that alg none, HS256 tokens and unknown issuers are rejected. A scan of service configurations finds services that are not on the starter, which usually are the ones that will break during a real rotation.
7Follow-up questions
Why not let services cache the JWKS for a day to reduce load?
Because a day-long cache means an emergency rotation takes a day to take effect, unless the service refetches on an unknown kid. With refetch on unknown kid and a refresh of a few minutes, the load on the JWKS endpoint is still tiny: 100 services fetching every 10 minutes is about one request every six seconds.
Should services validate tokens locally or call introspection?
Local validation with cached keys is the default, because it removes the identity provider from the request path and scales well. Introspection, where the service asks the identity provider whether a token is still valid, can be reserved for a few high-risk APIs that need immediate revocation.
How do you handle a service that cannot use the starter, for example a Node service?
The standard is written as rules, not as Spring code, so the same rules apply: fixed asymmetric algorithms, JWKS with refetch on unknown kid, and issuer, audience and expiry checks. The platform team provides a reviewed configuration for each supported language and the same contract tests.
8Conclusion
In this answer, we set a signing standard for 100 services. Only the identity provider signs user tokens, using RS256 or ES256 fixed in each service's configuration. Keys are published through JWKS with a kid, cached for minutes and refetched on an unknown kid. Rotation publishes the new key before using it and keeps the old one longer than the cache and token lifetimes. The platform starter delivers all of it, and rotation drills prove it works.
Open with
I would start with who signs. Only the identity provider signs user access tokens; services forward or exchange user tokens and use client credentials for their own calls, so there is one private key to protect instead of a hundred.
Then, if they want more
For algorithms, asymmetric only, RS256 or ES256, and fixed in each service's configuration, never taken from the token header, which rules out alg none and algorithm confusion. HS256 is out because every verifier would hold a key that can sign. Keys are published at a JWKS endpoint with a kid on every key.
Services cache the set for a bounded time, say ten minutes, and refetch immediately with a rate limit when they see a kid they do not know. That refetch is what makes emergency rotation take effect in seconds.
Planned rotation is: publish the new key, wait longer than the cache refresh, start signing with it, wait longer than the token lifetime, then remove the old key. With fifteen-minute tokens and ten-minute caches I would still use overlaps of a day for planned rotation.
To make this real across a hundred teams, the platform starter configures the decoder, algorithms, issuer and audience validation by default, contract tests check that bad tokens are rejected, and we rehearse rotation in staging monthly and in production quarterly.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- RFC 7519, JSON Web Token
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Define a token signing and validation standard for 100 services: who may sign tokens...": https://scrivio-interview-library.netlify.app/spring-boot/jwt/b616e58ca5/