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

Raise IncorrectAlgorithm if token has no alg header #411

Merged
merged 1 commit into from Apr 26, 2021

Conversation

bouk
Copy link
Contributor

@bouk bouk commented Mar 31, 2021

Closes #410

@sourcelevel-bot
Copy link

Hello, @bouk! This is your first Pull Request that will be reviewed by SourceLevel, an automatic Code Review service. It will leave comments on this diff with potential issues and style violations found in the code as you push new commits. You can also see all the issues found on this Pull Request on its review page. Please check our documentation for more information.

@sourcelevel-bot
Copy link

SourceLevel has finished reviewing this Pull Request and has found:

  • 2 possible new issues (including those that may have been commented here).

See more details about this review.

@@ -34,6 +34,7 @@ def decode_segments

def verify_signature
raise(JWT::IncorrectAlgorithm, 'An algorithm must be specified') if allowed_algorithms.empty?
raise(JWT::IncorrectAlgorithm, 'Token is missing alg header') unless header['alg']

Choose a reason for hiding this comment

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

JWT::Decode#verify_signature calls 'header['alg']' 2 times

Read more about it here.

@anakinj
Copy link
Member

anakinj commented Apr 26, 2021

Thanks for the fix.

As long as the alg header is required by the validation i think this is a great change. In general I think the alg header should be of almost no relevance and maybe we should make it less important when validating the signature.

@anakinj anakinj merged commit 3434f58 into jwt:master Apr 26, 2021
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.

NoMethodError: undefined method `zero?' for nil:NilClass if JWT has no 'alg' field
2 participants