-
Notifications
You must be signed in to change notification settings - Fork 911
feat: add jwt pkg #14928
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
Merged
feat: add jwt pkg #14928
Conversation
This file contains hidden or 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
This refactor encapsulates key management for JWT signing and verification by: - Introducing `ParseKeyFunc` and `SecuringKeyFn` to streamline key operations. - Moving key-related functions to `jwt.go` to improve package modularity. - Simplifying `Encrypt` and `Decrypt` function documentation and usage. - Updating tests to align with the new function signatures and logic flow.
The JWT functionality has been refactored, and its associated test values are no longer required. Removing the test file helps maintain code clarity and prevents outdated test logic from impacting the current codebase.
- Renamed key functions to clarify their use. - Removed unused `featureHeaderKey`. - Added comprehensive tests for JWT signing and verifying.
deansheather
reviewed
Oct 2, 2024
- Streamlines key retrieval by integrating with the cryptokeys package. - Simplifies key handling by decoding directly using hex utilities. - Enhances validation by using context for managing key operations. - Improves test robustness with clearer setup and consistent mocking.
- Rename package `jwt` to `jwtutils` for better context. - Consolidate constants and enhance error messages. - Simplify key management for JWT signing and verification.
deansheather
reviewed
Oct 3, 2024
Refactor JWT utility code to replace `ParseOptions` with more specific `VerifyOptions` and `DecryptOptions`. This change enhances clarity and flexibility, accommodating different needs for JWS and JWE operations. Update tests to align with the refactored structure, ensuring robust coverage and functionality verification.
Increase OIDC secret length for added security and clarity. Optimize JWT test coverage with custom claims and key cache tests.
Emyrk
reviewed
Oct 3, 2024
- Enhance comments for key interfaces to clarify usage and considerations for time validity and clock skew. - Refactor JWE/JWS logic to simplify serialization and deserialization processes, ensuring more efficient and concise handling of JWTs. Implement compact serialization and remove unnecessary base64 encoding.
Removing unused test and mock code simplifies maintenance and reduces clutter.
Deleting unnecessary cryptokeys keycachemock ensures clarity and reduces maintenance.
Ensure that the dbCache methods for encrypting, decrypting, signing, and verifying keys validate the feature flag before proceeding with operations. This validation step prevents using keys for unintended purposes, maintaining proper alignment with their intended cryptographic feature.
deansheather
approved these changes
Oct 4, 2024
Emyrk
approved these changes
Oct 4, 2024
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.
LG, would like to have the "fetcher" interface so we can use this in wsproxy too at some point 👍
Yeah I'll open an issue to work on a refactor once I get this running in dev. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This PR adds a
jwtutils
package to be shared amongst the various packages in the codebase that make use of JWTs. It's intended to help us standardize on one library instead of some implementations usinggo-jose
and others usinggolang-jwt
.The main reason we're converging on
go-jose
is due to its support for JWEs,golang-jwt
also has a repo to handle it but it doesn't look maintained