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

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

Closed
bouk opened this issue Mar 31, 2021 · 0 comments · Fixed by #411
Closed

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

bouk opened this issue Mar 31, 2021 · 0 comments · Fixed by #411

Comments

@bouk
Copy link
Contributor

bouk commented Mar 31, 2021

For example:

 JWT.decode('e30K.e30K.e30K')
=> NoMethodError: undefined method `zero?' for nil:NilClass

I'd expect this to throw a JWT::IncorrectAlgorithm, but casecmp here:

allowed_algorithms.any? { |alg| alg.casecmp(header['alg']).zero? }
returns nil if alg is not set, so we get an unexpected NoMethodError.

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 a pull request may close this issue.

1 participant