Allow secretOrPrivateKey in verify to be function(kid)
See original GitHub issueI currently use decode
to get the kid
, then use verify
with the correct key. This could be simplified if verify
would accept secretOrPrivateKey
to be a function(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 if verify
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?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:8 (6 by maintainers)
Top Results From Across the Web
How to solve "secretOrPrivateKey must have a value" in Node.js
I installed the dotenv dependency with the aim of storing my json web token secret inside it so as to avoid pushing a...
Read more >Error: secretOrPrivateKey must have a value - Stack Overflow
I am using jwt to create token, but when i login via postman I get the error "Error: secretOrPrivateKey must have a value"...
Read more >jsonwebtoken - npm Package Health Analysis - Snyk
stringify . secretOrPrivateKey is a string, buffer, or object containing either the secret for HMAC algorithms or the PEM encoded private key for...
Read more >node_modules/jsonwebtoken ... - Gitlab @ CCI
secretOrPrivateKey is a string, buffer, or object containing either the secret ... If jwt.verify is called asynchronous, secretOrPublicKey can be a function ......
Read more >How to Build a Full-Stack Authentication App With React ...
Check http://localhost:3000/ on your browser to confirm ... Next, you'll need to make a function to enable you to protect a particular ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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.
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?