-
Notifications
You must be signed in to change notification settings - Fork 0
Change JWT encryption from HMAC to RSA with rotating keys #37
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
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
…, modify jwt_helper to use RSA keys, and add entrypoint script for key generation
…anagement in jwt_helper, and modify .gitignore for key files
…mic key retrieval in token generation
…e sample token generation
…w jwtoken module, removing deprecated admin routes and cleanup scripts.
…le and removing deprecated keys_id module
…ting test fixtures into a new structure
Contributor
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.
Copilot reviewed 25 out of 28 changed files in this pull request and generated 1 comment.
Files not reviewed (3)
- .devcontainer/Dockerfile: Language not supported
- Dockerfile: Language not supported
- entrypoint.sh: Language not supported
Comments suppressed due to low confidence (1)
jwtoken/tokens.py:55
- [nitpick] Consider providing a more descriptive error message for token type mismatches to aid in debugging, such as including the expected type versus the received type.
raise jwt.InvalidTokenError("Invalid token type")
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Introduced key rotation logic to ensure keys directory and active_kid.txt file exist. - Updated key paths in the rotate_keys function to use constants from the new config file. - Created a new config file for JWT key management constants. - Refactored keys_cleanup.py to use the new CREATED_AT_FILE constant.
…rotation before starting the app; update keys_rotation.py for improved key management and error handling.
…_rotation modules
… startup; add entrypoint.sh for improved process management.
… port; ensure proper permissions are set for execution.
…ck; improve code readability.
…rify that it's pre-installed.
…e consistency and readability.
…run app.py; streamline container startup process.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
complexity: experimental
Tasks exploring untested tools or approaches for infrastructure or deployment.
priority: high
Important tasks that require immediate attention.
status: completed
Fully implemented and verified.
type: security
Issues or improvements related to app security.
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.
Brief Description of Changes
This pull request upgrades the JWT security model from HS256 (HMAC with SHA-256) to RS256 (RSA with SHA-256) and introduces support for rotating RSA keys using KIDs (Key IDs).
Detailed Changes
kidto identify which public key to use during verification.kidin the JWT header.kidis missing, invalid, or points to an unknown public key.Objective of Changes/Issue Resolved (if applicable)
This change improves the security, maintainability, and scalability of our JWT authentication system. By using RS256:
By adding KID-based rotation:
Resolves the problem of shared-secret risks and improves future readiness for distributed and multi-tenant environments.
Screenshots (if applicable)
Not applicable.
Verification Steps
JWT_PRIVATE_KEY,JWT_PUBLIC_KEYS(map of KIDs to public keys), andJWT_ACTIVE_KID.kid.kid.Notes for Reviewer
JWT_PUBLIC_KEYS) and howJWT_ACTIVE_KIDis injected into the JWTs.