How to get encrypted JWT string in passport-jwt?
bigturtle88 opened this issue · 2 comments
I am using Express.js, Passport.js. Jsonwebtoken
I save a JWT encoded token in the database.
I want to check encrypted JWT with Bearer.
JwtStrategy allows us to receive the jwtPayload object.
But I need to get an encrypted string. The documentation contains rawJwt (Token), but how to get encrypted string? How to extract?
passport.use(new JwtStrategy({
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
secretOrKey : config.secretOrKey
},
function (jwtPayload, cb) {
return User.find({_id: jwtPayload.user._id, token: token}) // compare the token that goes in encrypted form
.then(user => {
return cb(null, user);
})
.catch(err => {
return cb(err);
});
})
Any idea on this?
Unfortunately, I'm not able to asnwer basic implementation questions like this due to limited time. If you discover a reproducible issue with this module please open an issue with a unit test, succinct code snippet or detailed instructions to reproduce.
Consider asking a question on stack overflow or look into one of the many tutorials on jwt auth in passport (many of them refer to this module). Best of luck.