Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get encrypted JWT string in passport-jwt? #189

Closed
bigturtle88 opened this issue Dec 7, 2019 · 2 comments
Closed

How to get encrypted JWT string in passport-jwt? #189

bigturtle88 opened this issue Dec 7, 2019 · 2 comments

Comments

@bigturtle88
Copy link

bigturtle88 commented Dec 7, 2019

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);
          });
  })
@sebas-deedee
Copy link

Any idea on this?

@mikenicholson
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants