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

If token is not HS256 using a verifier instance will throw a JwtParseError "Unexpected signature algorithm" #73

Open
Anntoin opened this issue Aug 4, 2020 · 1 comment

Comments

@Anntoin
Copy link

Anntoin commented Aug 4, 2020

If using a different algorithm to the default (HS256) it must be set manually before calling verify, otherwise will get an "Unexpected signature algorithm" due to the check here https://github.com/jwtk/njwt/blob/master/index.js#L361

The example here should probably call this behaviour out https://github.com/jwtk/njwt#using-a-key-resolver

This tripped me up for a while when verifying a AWS Cognito token

@vitaliytv
Copy link

add setSigningAlgorithm, for example:

var verifier = nJwt.createVerifier().withKeyResolver(myKeyResolver)
verifier.setSigningAlgorithm('ES256')

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

No branches or pull requests

2 participants