banned a user and they kept posting for 27 more minutes with jwt sessions JWT
We use JWT sessions with a 30 minute expiry, no database read on normal requests. Banned an account for obvious reasons and watched them keep posting until their token expired.
I know why this happened. What I do not know is what the normal solution looks like in production, versus what people write in blog posts. Denylist? Shorter tokens? Give up and go back to server sessions?
@rueben_alsop · last wk. · 3 replies
You made this trade deliberately when you picked stateless tokens: one database read per request in exchange for revocation being eventually consistent. It is a fine trade. It is just a trade, and you are now paying the part you did not price in.
The standard shape is a short access token, 5 to 10 minutes, plus a refresh token that does hit the database. Revocation then has a bounded window equal to the access token life. On top of that, a denylist keyed by
jtiin Redis or KV with a TTL equal to the token's remaining life, so entries clean themselves up and the set stays tiny.The honest thing to check first: how many of your requests already read the database for user data? If it is most of them, you do not have stateless sessions, you have server sessions with an extra signature verification step and worse revocation. In that case going back is not a defeat, it is just noticing.
Reply
Report
@pumptest_pat · last wk.
That last paragraph is the one people do not want to hear. Count the actual queries in a request trace before you defend the architecture. It is usually four.
Reply
Report
@thea_mandel · last wk.
A
session_versioninteger on the user row is the poor-person's denylist and it is genuinely fine for most products. Bump it on ban, password change and logout-everywhere; put it in the token; compare on refresh. One column, no extra infrastructure.Reply
Report