question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow secretOrPrivateKey in verify to be function(kid)

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
JacoKostercommented, Jun 3, 2018

@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.

1reaction
Richie765commented, Sep 29, 2017

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found