Open sbaker opened 4 years ago
There is no need to add this functionality. You could simply add a custom middleware that performs any async task you need, then put the result in the request object. Finally, extract the custom req
field inside jwtFromRequest
and return it so passport-jwt can process it.
I agree it can be done that way as well as others. In knowing what I've learned I think that this functionality is and will be needed . This PR doesn't change any existing functionality only adds more flexibility for the developer.
https://github.com/mikenicholson/passport-jwt/blob/6b92631dfbde7143b9e046093dbf332107bce82e/lib/strategy.js#L93
options._jwtFromRequest may return a Promise in some scenarios.
Currently, We issue reference tokens that basically are pointers to the actual JWT on our IDP. I have to make an HTTP call to our IDP for exchanging the reference token for the actual JWT forcing me to return a promise.