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

Support for ES256/ES384/ES512 #164

Merged
merged 17 commits into from
Jul 17, 2024
Merged

Support for ES256/ES384/ES512 #164

merged 17 commits into from
Jul 17, 2024

Conversation

ottokruse
Copy link
Contributor

@ottokruse ottokruse commented Jul 1, 2024

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 the JwtVerifier. For backward compatibility, I added an alias from JwtRsaVerifier to JwtVerifier 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 generic JwtVerifier 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, the alg on the Cognito JWKs is leading for which alg is supported anyway, which currently is always RS256,RS384,RS512. I've also added some docs on how the alg from the JWK must match the alg 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.

@ottokruse ottokruse requested a review from hakanson July 1, 2024 13:32
package.json Outdated Show resolved Hide resolved
format: "jwk",
}) as Jwk;
jwk.alg =
"alg" in options ? options.alg : options.kty === "RSA" ? "RS256" : "ES256";
Copy link
Contributor

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" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

@ottokruse ottokruse merged commit 361fc8c into awslabs:main Jul 17, 2024
1 check passed
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.

[BUG] Library forces presence of optional "use" field in JWKS key
2 participants