.NET › Authentication & Authorization (Identity, JWT, OAuth)
How does token revocation work with stateless JWTs, given they can't simply be 'deleted' server-side once issued?
AdvancedAnswer
Since JWTs are self-contained and valid until expiration regardless of server-side state, true revocation requires either: keeping token expiration very short combined with refresh token revocation (revoke the refresh token so no new access tokens can be issued, while the current one simply expires soon), or maintaining a server-side denylist/blocklist of revoked token IDs (jti claim) checked on every request -- which reintroduces some statefulness, trading off JWT's original stateless benefit for revocation capability.
// Denylist approach: check jti against a fast cache (e.g., Redis) on each request
var jti = User.FindFirst(JwtRegisteredClaimNames.Jti)?.Value;
if (await _revokedTokenCache.ExistsAsync(jti)) {
return Results.Unauthorized();
}Real-world example A security incident forces immediate logout of a compromised account; the team adds the affected user's active token jti values to a Redis-backed denylist checked by a custom authorization handler on every request until those tokens naturally expire.