Ravi Gupta’s Post

Logout in AuthShield was supposed to be straightforward. User clicks logout. Token gets invalidated. Done. Except a JWT cannot be invalidated. It is a signed string. There is nothing to delete. It just keeps working until it expires. That one realization pulled on everything else. If logout needs a blacklist, access tokens need to be short-lived so the blacklist stays small. If tokens are short-lived, users cannot stay logged in without constantly re-authenticating. That means two tokens - a short-lived access token for requests, a long-lived refresh token to silently replace it. But a long-lived refresh token is a theft target. So it rotates on every use. But rotation alone does not stop an attacker who uses the token before the real user does. Token families. Every refresh token belongs to a chain tied to a single login. The moment an already-rotated token is used again, the entire chain is revoked. Attacker and real user both get logged out. Four problems. Each one hiding behind the previous one. Full breakdown with the Python implementation in the blog. Link in the comments 👇 #BackendEngineering #Python #JWT #Security #Authentication #SoftwareEngineering

  • diagram, schematic

Here is the full Phase 2 deep dive 👇 https://dev.to/ravigupta97/i-thought-jwts-were-stateless-turns-out-logout-made-me-build-a-stateful-layer-anyway-48nd JWTs, logout, Redis blacklisting, the two-token strategy, refresh token rotation, and token family reuse detection - the complete token security implementation in AuthShield. GitHub: https://github.com/ravigupta97/authshield

Like
Reply

To view or add a comment, sign in

Explore content categories