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

Empty secret or public key #72

Merged
merged 4 commits into from
Jul 15, 2015
Merged

Empty secret or public key #72

merged 4 commits into from
Jul 15, 2015

Conversation

JackuB
Copy link
Contributor

@JackuB JackuB commented Mar 30, 2015

When secret or key fails to load or is not provided, verify can throw error even with callback.

Added check for null and undefined

@@ -107,6 +107,9 @@ module.exports.verify = function(jwtString, secretOrPublicKey, options, callback
return done(new JsonWebTokenError('jwt signature is required'));
}

if (typeof secretOrPublicKey === "undefined" || secretOrPublicKey === null) // secretOrPublicKey can be empty string

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we change this to just:

if (!secretOrPublicKey) {
  return done(new JsonWebTokenError('secret or public key must be provided'));
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jtwebman I got impression, that key is allowed to have value of '' (empty string).

Seems safer to check even for empty string, updated code.

@jfromaniello jfromaniello merged commit f1cffd0 into auth0:master Jul 15, 2015
@jfromaniello
Copy link
Member

Thank you very much, published as v5.0.4.

@JackuB JackuB deleted the empty_secretOrPublicKey branch July 16, 2015 06:36
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

Successfully merging this pull request may close these issues.

3 participants