-
Notifications
You must be signed in to change notification settings - Fork 44
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
Support for ES256/ES384/ES512 #164
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hakanson
reviewed
Jul 5, 2024
hakanson
reviewed
Jul 5, 2024
format: "jwk", | ||
}) as Jwk; | ||
jwk.alg = | ||
"alg" in options ? options.alg : options.kty === "RSA" ? "RS256" : "ES256"; |
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.
for EC, can we default to ES256 or is that only valid if named curve parameter is "P-256" ?
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.
OK
hakanson
approved these changes
Jul 11, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #, if available: #87 (but that was not the main point of this PR)
Description of changes: This PR adds support for verifying JWTs that were signed with ES256/ES384/ES512.
This is a necessary step in order to e.g. add an AWS ALB JWT verifier #109
I've added support for ES256/ES384/ES512 by making the previous
JwtRsaVerifier
more generic: it has now become theJwtVerifier
. For backward compatibility, I added an alias fromJwtRsaVerifier
toJwtVerifier
that should cover most simple cases––but all in all this PR is a pervasive change; for example several types were changed and these changes are likely to be breaking for some users. Thus we should release the updated code in a new major version.Interestingly the
CognitoJwtVerifier
now also supports verifying ES256/ES384/ES512 signed JWTs, because it subclasses the same machinery that the genericJwtVerifier
uses, but I see this not as an issue. If Cognito would ever start using ES256/ES384/ES512 it means this lib will just work as is. Also, thealg
on the Cognito JWKs is leading for whichalg
is supported anyway, which currently is always RS256,RS384,RS512. I've also added some docs on how thealg
from the JWK must match thealg
on the JWT header.ALSO TAKE NOTE: we no longer support Node 14 but now require Node 16. This seems reasonable since Node 14 is really old by now (even 16 is). The benefit to the codebase of dropping Node 14 support and requiring Node 16 is that we no longer need the custom ASN.1 decoder. So we got rid of some code 🎉
While at it, also fixed #87 because it was low hanging fruit in a piece of code I was touching.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.