-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Allow secretOrPrivateKey in verify to be function(kid) #406
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
Comments
Good one, I've seen that in other libraries (like express-jwt). I think it is better to pass a more generic function like: That open the use case for jwks, where based on the issuer you could reach their public keys. What do you think? |
I think it's a bit risky. I'm not trusting the jwtClaims until the signature check has passed. The one to decide which is the issuer is the client, not the token. Otherwise anyone could put any issuer in the token and make the signature check pass. I would avoid that and just pass the jwtHeaders (or just kid). I'm not very familiar with jwks, so what do you think? |
I pasted the link in the PR and I gave you feedback there. (https://auth0.com/docs/jwks) |
i got this mistake :/ secretOrPrivateKey must have a value on jsonwebtoken :/ |
@ziluvatar @Richie765 I have asked this question in the PR as well, but what needs to be done to move this along? It has been open for quite some time, i have added the relevant tests and was hoping this could be part of a new major release. I'd be happy to do contribute, but i'd prefer not to be waiting for weeks on a response. |
Good to hear that. I answered in the PR:
|
@ziluvatar I have opened a new PR for this, which has the functionality from the original PR, but without the breaking changes. I am eager to see if this is ok. |
Fixed by: #480 |
I currently use
decode
to get thekid
, then useverify
with the correct key. This could be simplified ifverify
would acceptsecretOrPrivateKey
to be afunction(kid)
so this could be handled in one step.I could make a PR in the coming weeks, would this be accepted?
EDIT: I just realize that
function(kid)
would probably fetch the key asynchronously from the AP. In that case the function would return a promise. That can only work ifverify
is called asynchronously. I think it's possible to implement this backwards compatible. Perhaps in the future the whole library should be made with promises instead of callbacks? Any thoughts?The text was updated successfully, but these errors were encountered: