【发布时间】:2017-03-04 10:07:15
【问题描述】:
我正在使用 passport-jwt 生成我的令牌,但我注意到令牌永不过期,有没有办法根据为我设置的规则使特定令牌无效,例如:
'use strict';
const passport = require('passport');
const passportJWT = require('passport-jwt');
const ExtractJwt = passportJWT.ExtractJwt;
const Strategy = passportJWT.Strategy;
const jwt = require('../jwt');
const cfg = jwt.authSecret();
const params = {
secretOrKey: cfg.jwtSecret,
jwtFromRequest: ExtractJwt.fromAuthHeader()
};
module.exports = () => {
const strategy = new Strategy(params, (payload, done) => {
//TODO: Create a custom validate strategy
done(null, payload);
});
passport.use(strategy);
return {
initialize: function() {
return passport.initialize();
},
authenticate: function() {
//TODO: Check if the token is in the expired list
return passport.authenticate('jwt', cfg.jwtSession);
}
};
};
或一些使某些令牌无效的策略
【问题讨论】:
-
你能解决吗?
标签: node.js express passport.js jwt