jwt令牌已过期,但passport.authenticate不会返回401

时间:2020-04-01 13:19:45

标签: node.js express jwt passport.js passport-jwt

passport.authenticate似乎始终允许访问,即使JWT令牌已过期。这是代码段

var cookieExtractor = function(req) {
  var token = null;
  if (req && req.cookies) {
    token = req.cookies['access_token']

    if (token)
      token = token.replace("Bearer ","")
  }
  console.log('token=')
  console.log(token)

  return token;
};

const options = {
  jwtFromRequest: cookieExtractor,
  secretOrKey: PUB_KEY,
  ignoreExpiration: false
}


module.exports = (db) => {

  passport.use(new JwtStrategy(options, (jwtPayload, done) => {


0 个答案:

没有答案