-
Notifications
You must be signed in to change notification settings - Fork 377
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
Ignore casing of algorithm #405
Conversation
Hello, @johnnyshields! 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. |
There might be something wrong with how the gem handles the Ed25519 cases (#334). In general i think that making the algorithms case insensitive is maybe not a good idea. The RFCs clearly states what the values are expected to be (https://tools.ietf.org/html/rfc7518#page-9). |
It's reasonable to expect that there will case insensitive JWT implementations in the wild. Perhaps we can always encode to correct casing (uppercase), but decode irrespective of case? |
I agree that that the parameter given in the Just to compare the OpenSSL API is case insensitive and allows both uppercase and lowercase:
|
Im fine with either just doing the change in #406 or then make some adjustments to this that the |
OK, I've updated this PR to show what it would look like to add casing coercion (e.g. "hs256" becomes "HS256" when encoding). There are still some failing specs related to unsupported case. If you like this implementation I will fix the failing specs over the weekend. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really great. I added a few questions
Thank you for your contribution. |
(Updated 2/6/2021)
I am have to connect to a third party source for JWTs which transmits the algorithm as "Ed25519". This does not match the expected value in Ruby "ED25519". To remedy this:
In order to achieve this in a clean manner, I've extracted out a
JWT::Algos
module which uses a more efficient lookup (pre-indexed) to find the algo. I've also introducedJWT::Algos::None
which is distinct fromJWT::Algos::Unsupported