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

Token encoded with empty string payload throw invalid token error on verify() #800

Open
BlairCurrey opened this issue Dec 16, 2021 · 1 comment

Comments

@BlairCurrey
Copy link

BlairCurrey commented Dec 16, 2021

Description

When you sign a key with an empty string as a payload, the verification throws JsonWebTokenError: invalid token. Instead, I expect it to return the empty string, ''. If this can't be accomplished, then I think it should fail to sign with some sort of invalid payload error. I wouldn't expect it to be possible to sign something that cannot be verified.

Reproduction

> jwt.sign('', 'someKey')
'eyJhbGciOiJIUzI1NiJ9..4Q39XnmJ95pIs0bJ05Gq_byy31eRYSrlmhrgKI5FHkk'
> jwt.verify('eyJhbGciOiJIUzI1NiJ9..4Q39XnmJ95pIs0bJ05Gq_byy31eRYSrlmhrgKI5FHkk', 'someKey')
Thrown:
JsonWebTokenError: invalid token
    at Object.module.exports [as verify] (/home/project/node_modules/jsonwebtoken/verify.js:75:17) {
  name: 'JsonWebTokenError',
  message: 'invalid token'
}

Environment

jsonwebtoken: 8.5.1
node v12.13.0

@danielwust
Copy link

I had this problem,
Changing the format from AuthOAuth2JWTToken to AuthJWTToken and it worked.

Good lucky..

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