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 RS256 JWTs #99

Closed
wants to merge 23 commits into from
Closed

Conversation

cole-h
Copy link
Collaborator

@cole-h cole-h commented Nov 12, 2023

Fixes #95.


While this adds support for RS256 JWTs, it does not remove support for HS256 JWTs. That said, it does recommend using RS256 in documentation.

We switched to using the jsonwebtoken crate since that's what we're most familiar with, but I can probably switch back to jwt_simple if that is so desired.

cole-h and others added 17 commits November 11, 2023 12:58
There are some 2021-edition crates that Cargo was warning about.
So it's Base64<PEM bytes>, not just PEM bytes.
The JWT spec [1] basically says that JWTs must validate the `aud` claim
if its specified:

> If the principal
> processing the claim does not identify itself with a value in the
> "aud" claim when this claim is present, then the JWT MUST be
> rejected.

[1]: https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.3
Since we now validate the `sub` and `nbf` claims, they need to be set
when atticadm generates them.
@zhaofengli
Copy link
Owner

Hi there, thanks for the PR! Using RS256 definitely makes more sense in production scenarios. I would appreciate if jwt_simple is used - I switched to it from jsonwebtoken specifically so that the token crate works inside WebAssembly.

This effectively reverts commit 3e0b65a.

Because jwt_simple doesn't have a unified type / trait that allows
signature and verification, I had to add a SignatureType enum to
approximate that.
@cole-h
Copy link
Collaborator Author

cole-h commented Nov 12, 2023

OK, done in 0a9d493!

@fd
Copy link

fd commented Nov 28, 2023

This would be incredibly useful to us.

@cole-h
Copy link
Collaborator Author

cole-h commented Feb 26, 2024

Sorry for the delay -- pubkey-only validation is now supported as of 756fef8.

@niklaskorz
Copy link

@zhaofengli Are there any more required changes for this to be merged?

@cole-h
Copy link
Collaborator Author

cole-h commented Jul 26, 2024

(Probably one thing would be addressing the conflicts, which I've done now)

@apexo
Copy link

apexo commented Sep 24, 2024

How is this better than HS256 in the context of attic? I've left a longer comment here: #95 (comment)

This was referenced Oct 4, 2024
@zhaofengli
Copy link
Owner

I'll be merging this in #177.

@zhaofengli zhaofengli closed this Oct 5, 2024
@cole-h cole-h deleted the rs256-support branch October 7, 2024 14:22
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.

Asymmetric JWTs?
6 participants