fix(auth/middleware): return 401 instead of 500 for malformed tokens#79
fix(auth/middleware): return 401 instead of 500 for malformed tokens#79
Conversation
checkAuthorization returned HTTP 500 when JWT parsing failed (malformed/invalid token). The Authorize caller also hardcoded 500, ignoring the returned status code. Now returns 401 Unauthorized for parse failures and the caller respects the returned status code. X-Lerian-Ref: 0x1
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe authorization middleware now returns more appropriate HTTP status codes for authentication failures. When token parsing or claims extraction fails, the response now returns 401 Unauthorized instead of 500 Internal Server Error. The 🚥 Pre-merge checks | ✅ 1 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📝 Coding Plan
Comment Tip CodeRabbit can use TruffleHog to scan for secrets in your code with verification capabilities.Add a TruffleHog config file (e.g. trufflehog-config.yml, trufflehog.yml) to your project to customize detectors and scanning behavior. The tool runs only when a config file is present. |
gandalf-at-lerian
left a comment
There was a problem hiding this comment.
Straightforward and correct. Malformed/invalid tokens are a client problem, not a server problem — 401 is the right response. The Authorize handler now actually uses the returned statusCode instead of hardcoding 500, which was a silent bug. Test updated to match. LGTM ✅
|
🎉 This PR is included in version 2.5.0-beta.8 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
checkAuthorization returned HTTP 500 when JWT parsing failed (malformed/invalid token). The Authorize caller also hardcoded 500, ignoring the returned status code.
Now returns 401 Unauthorized for parse failures and the caller respects the returned status code.
X-Lerian-Ref: 0x1
Pull Request Checklist
Pull Request Type
Checklist
Please check each item after it's completed.
Additional Notes
Obs: Please, always remember to target your PR to develop branch instead of main.