3 ms·
There are viable solutions to the JWT revocation problem: 1. Make JWTs short-lived (10 mins or less), and use refresh tokens. 2. Note that for many apps, espe
by hn_throwaway_99 5y ago
There are viable solutions to the JWT revocation problem:
1. Make JWTs short-lived (10 mins or less), and use refresh tokens.
2. Note that for many apps, especially native mobile apps, a user rarely, of ever, logs out. And you only need to keep a revocation list around as long as it takes a token to expire, so your revocation list is often VERY small and thus can be kept in memory.
3. Thus, when a user logs out, they make a call to your server, and you store the user ID and timestamp - any JWTs issued before that time are considered invalid.
4. Write this data to postgres in a simple table. Then, using postgres NOTIFY functionality to update all your servers with the in-memory revocation list.
5. When checking a JWT, you validate the signature and check it against the revocation list.
This won't work in all cases if for some reason your revocation list is too big to fit in memory, but even then it's easy to extend it to a backing store if you outgrow this solution.