DEV Community

Discussion on: Remaining Stateless - Using Redis for token blacklisting in Node JS

Collapse
 
dgroh profile image
Daniel Groh

Why don't u simply use Setx with the expiration date? Then just check if the token exists...Setx will automatically remove the token from the store once it expires even if you don't logout. Why should I keep a list of blacklisted tokens in Redis? Or did I miss the point?

Collapse
 
thegarlynch profile image
thegarlynch

you can also set expiration date for blacklisted item too. it will cause, lesser storage theoritically because you need to invalidate explicitly by logout. but it needs
"appendfsync always". otherwise, blacklisted item unintentionnally disappeared and make it worse than having authenticated token disappeared (since you can always login)

Collapse
 
princebillygk profile image
Prince Billy Graham Karmoker

I am also thinking so it will also remove the chance of duplication with deleting the token on expiration. This comment deserves more votes