I am using the jwt-simple
node module:.
How can I do blacklisting tokens?
I am using the jwt-simple
node module:.
How can I do blacklisting tokens?
Long story short, you don't.
You set short expire times and wait for the token to expire.
If you need quick logout, it come at the price of needing your app to log in often.
Robert Rossman answer explain a alternative way to do that.
easy way to blacklist or destroy the jwt token:
using jwt-blacklist
module
install it via $ npm install jwt-blacklist
example:
const jwt = require('jsonwebtoken');
const jwtBlacklist = require('jwt-blacklist')(jwt);
let token = jwtBlacklist.sign({
feeling: 'awesome'
}, 'secret', {expiresIn: '2h'});
jwtBlacklist.blacklist(token); // destroy the token
jwtBlacklist.verify(token); // throw error token expired or destroyed
1) Simply remove the token from the client
2) Create a token blacklist
3) Just keep token expiry times short and rotate them often
Please have a look at Invalidating JSON Web Tokens