Scrivio Interview library
DesignIntermediate6 min read · updated 12 November 2026

A fraud team needs to block a compromised account's JWT access tokens within one minute across 30 services. Tokens live for 15 minutes. Design a solution.

Keep a deny list of revoked user ids or token ids (jti), each with a not-before time, in a fast shared store or pushed to services, and check it in the gateway or a shared resource server validator with local caching of a few seconds. At the same time revoke the account's refresh tokens at the identity provider so no new access tokens are issued. Deny-list entries can expire after the maximum access token lifetime, here 15 minutes, and for high-risk APIs introspection or shorter tokens are alternatives.

Why this question is asked

Stateless JWT validation is attractive precisely because a service never has to ask anyone whether a token is still good. That same property becomes a problem the moment a fraud analyst says an account is compromised and must be stopped now. With 15-minute tokens, waiting for expiry would leave up to 15 minutes of damage, and the requirement is one minute. Interviewers ask this design question to see whether we can add just enough state to meet a revocation target without throwing away the benefits of JWTs. In this answer, we will recap why JWTs are hard to revoke, design the deny list and where it is checked, handle refresh tokens, size the store and its expiry, and compare the alternatives.

1Why a JWT Cannot Simply Be Revoked

Each of the 30 services validates an access token locally: it checks the signature with the identity provider's public key and checks claims such as exp (expiry) and aud (audience). No call goes to the identity provider. So if the identity provider marks the account as compromised, the services do not hear about it, and every access token already issued keeps working until exp, up to 15 minutes.

To revoke within one minute, the services need one small piece of shared, fast-changing state: a list of what has been revoked. The design is about making that state cheap to check and quick to spread.

2Designing the Deny List

Revoking individual tokens is awkward, because the fraud team does not know which tokens the attacker holds. Revoking the account is what they need. So the main entry is keyed by user id (the sub claim) and holds a not-before time: any token for that user issued before that moment is rejected. Tokens issued after it, for example after the real user signs in again with a reset password, are accepted. Entries keyed by token id (the jti claim, a unique id per token) are useful too, for revoking one stolen token without logging the user out of every device.

Java
// written by the fraud tool when an account is blocked at 14:02:10
SET revoked:user:8f31 "1762437730" EX 960 // not-before epoch seconds, expire after 16 min
// checked for each token
// token sub=8f31, iat=14:00:05 -> iat < not-before -> reject (401)
// token sub=8f31, iat=14:05:40 -> iat >= not-before -> accept
// token sub=77aa -> no entry -> accept

Notice the expiry on the entry. Any token issued before the not-before time has an iat at most 15 minutes before it, so after 15 minutes plus clock skew, every such token has expired by itself. The entry is no longer needed and can disappear, which keeps the deny list tiny: it only ever holds the accounts revoked in the last quarter of an hour.

3Where the Check Runs and How It Stays Fast

The cleanest place is the API gateway, if all 30 services sit behind it: one check, one implementation, and the services need no change. If some services are reached without the gateway, for example from other internal services, the check also goes into the shared resource server configuration in the platform starter, as an extra OAuth2TokenValidator on the JwtDecoder that rejects tokens on the deny list.

Java
class DenyListValidator implements OAuth2TokenValidator<Jwt> {
private final RevocationCache cache; // local copy, refreshed every few seconds
public OAuth2TokenValidatorResult validate(Jwt jwt) {
Instant notBefore = cache.notBefore(jwt.getSubject(), jwt.getId());
if (notBefore != null && jwt.getIssuedAt().isBefore(notBefore)) {
return OAuth2TokenValidatorResult.failure(
new OAuth2Error("invalid_token", "Token revoked", null));
}
return OAuth2TokenValidatorResult.success();
}
}
Step throughBlocking an account within a minute
Fraud toolIdentity providerDeny-list storeService instance
Revoke refresh tokens for user 8f31
SET not-before for 8f31, expire 16 min
Refresh local copy (every 10 s)
Entries changed in last 16 min
Token sub=8f31, iat before not-before
Reject with 401

6 messages in order. Play them, or step through them one at a time.

The check must not add a network call to every request. Each instance keeps a local copy of the deny list and refreshes it every 5 to 10 seconds from the shared store, such as Redis, or receives updates pushed through a topic such as Kafka or Redis pub/sub. A full refresh is cheap because the list is small. With a 10-second refresh and a few seconds for the fraud tool to write the entry, revocation takes effect in well under the one-minute target. If the store is unreachable, the service keeps using its last copy and alerts, rather than failing open or rejecting everyone; that choice should be agreed with security.

4Stopping New Tokens at the Source

The deny list only handles access tokens already issued. The attacker may also hold a refresh token and keep getting fresh access tokens. So the same fraud action calls the identity provider to revoke every refresh token and session of the account and, typically, to lock it or force a password reset. From then on, no new token is issued to the attacker, and the deny list only needs to cover the tokens that were already out.

This is why the two halves belong together. Revoking refresh tokens alone would leave up to 15 minutes of live access tokens. The deny list alone would need entries that never expire, because the attacker could keep refreshing.

5Alternatives and When They Fit

Shortening access tokens to one minute would meet the target without a deny list, but it multiplies refresh traffic by 15 and makes every client refresh constantly, which is usually too high a cost for 30 services. Token introspection, where the service asks the identity provider about each token, gives immediate revocation but puts the identity provider on every request's path; it fits a few high-risk APIs such as payments, often with a short cache. A hybrid is common: deny list for all services, introspection for the riskiest endpoints.

Options to meet a one-minute revocation target
OptionRevocation delayCost
Deny list with local cacheSeconds (cache refresh)Small shared store, small code in starter
Access tokens of 1 minuteUp to 1 minute15 times more refreshes, client churn
Introspection on every callImmediateIdentity provider on every request path
Hybrid: deny list + introspection for paymentsSeconds / immediateBoth, but only where needed

6Follow-up questions

Why key the deny list by user and not only by jti?

Because the fraud team usually does not know which token ids the attacker holds. A user-level not-before time revokes every token issued before the block, on every device, with one entry. Token-id entries remain useful for revoking one specific leaked token.

What if a service's clock is a minute off?

The not-before comparison uses the token's iat, set by the identity provider, against a time also set centrally, so service clocks matter less. Still, we keep clocks synchronised and add a small margin to the entry's expiry.

How do you test that it works?

With a drill in staging: issue a token, block the account, and measure how long until every service rejects it. Run it regularly and alert if it ever takes longer than the target.

7Conclusion

In this answer, we met a one-minute revocation target for 15-minute JWTs across 30 services. A deny list keyed by user id, and optionally jti, with a not-before time, is written by the fraud tool, checked at the gateway or in a shared validator, and cached locally for a few seconds. The identity provider revokes the account's refresh tokens at the same time, entries expire after the maximum token lifetime, and introspection or shorter tokens remain options for the riskiest APIs.

What to say in the interviewAbout 90 seconds aloud

Open with

The problem is that each service validates JWTs locally, so revoking the account at the identity provider does nothing to the access tokens already out there, and those live up to fifteen minutes.

Then, if they want more

To get to one minute I would add a small deny list. When the fraud team blocks an account, the tool writes an entry keyed by the user id with a not-before time, meaning any token for that user issued before that moment is rejected. Optionally we also support entries by token id for revoking one specific token.

The entry goes into a fast shared store like Redis with an expiry of about sixteen minutes, because after the maximum token lifetime all older tokens have expired anyway, so the list stays tiny.

The check runs at the gateway if everything goes through it, and also as an extra token validator in the shared resource server starter, so internal calls are covered.

Each instance keeps a local copy refreshed every five to ten seconds or updated by a pub/sub message, so there is no network call per request and revocation takes effect in seconds. At the same time the fraud tool revokes all the account's refresh tokens at the identity provider, so no new access tokens are issued.

For the highest-risk APIs like payments, I might use introspection instead, and I would prove the whole thing with a regular drill that measures time to rejection.

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 "A fraud team needs to block a compromised account's JWT access tokens within one minute...": https://scrivio-interview-library.netlify.app/spring-boot/jwt/90d8b70a70/