tyk
tyk copied to clipboard
[TT-12495] Add support for RSASSA-PSS signed JWTs
Adding support for the more secure RSA-PSS signed JWTS.
Description
allows for the use of the RSA-PSS signature algorithm commonly referred to as PS256, PS384, PS512. The change is invisible to existing RSA Public Keyuse cases. Simply - by using "RSA Public Key" signing algorithm, Tyk will now validate JWTs signed by both RS & PS Class algorithms using Public Keys.
Motivation and Context
RSA-PSS is considered more secure than PKCS1 v1.5 due to its probabilistic nature, which helps mitigate certain attacks (e.g., padding oracle attacks).
RS256: Commonly used in legacy systems, JWT (JSON Web Tokens), and many existing protocols where backward compatibility is important. PS256: Recommended for new applications where higher security is desired. It is becoming more widely adopted in modern security protocols.
How This Has Been Tested
Unit tests have been added. Both positive + negative tests that test both RS class JWTs and PS class JWTs.
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality)
Checklist
- [ ] I ensured that the documentation is up to date
- [ ] I explained why this PR updates go.mod in detail with reasoning why it's required
- [ ] I would like a code coverage CI quality gate exception and have explained why
PR Reviewer Guide 🔍
| ⏱️ Estimated effort to review [1-5] | 3 |
| 🧪 Relevant tests | Yes |
| 🔒 Security concerns | No |
| ⚡ Key issues to review |
Error Handling Consistency: The error message in mw_jwt.go for the RSAPSS check could be more consistent with other error messages in the same function. Consider using a similar format for clarity and uniformity.
|
API Changes
no api changes detected
PR Code Suggestions ✨
| Category | Suggestion | Score |
| Possible bug |
Add nil check for token.Header to prevent runtime errorsTo avoid potential nil pointer dereference, add a nil check for
Suggestion importance[1-10]: 9Why: Adding a nil check for | 9 |
| Maintainability |
Consolidate conditional checks into a single statement for clarityTo improve the readability and maintainability of the JWT signing method assertion,
Suggestion importance[1-10]: 8Why: Consolidating the checks into a single conditional statement improves code readability and maintainability without altering functionality. | 8 |
| Enhancement |
Add a test case for RSAPSS signing methodTo improve the test coverage and ensure the RSAPSS signing method is correctly handled, gateway/mw_jwt_test.go [1628-1657]
Suggestion importance[1-10]: 8Why: Adding a specific test case for RSAPSS improves test coverage and ensures that the RSAPSS signing method is correctly handled. | 8 |
Add assertions to check JWT contents in testsTo ensure the robustness of the JWT parsing tests, add assertions to verify the contents gateway/mw_jwt_test.go [1614-1625]
Suggestion importance[1-10]: 7Why: Adding assertions to verify the contents of the parsed JWT enhances test robustness and ensures the JWT is parsed correctly. | 7 |
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
100.0% Coverage on New Code
0.0% Duplication on New Code
Let's make that PR title a 💯 shall we? 💪
Your PR title and story title look slightly different. Just checking in to know if it was intentional!
| Story Title | JWT RSA PUB Improvement - Support RSAPSS |
|---|---|
| PR Title | [TT-12495] Add support for RSASSA-PSS signed JWTs |
Check out this guide to learn more about PR best-practices.
/release to release-5.7
Working on it! Note that it can take a few minutes.
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
@andrei-tyk Seems like there is conflict and it require manual merge.
/release to release-5.3
Working on it! Note that it can take a few minutes.
@andrei-tyk Succesfully merged PR