laserninja opened a new pull request, #10673:
URL: https://github.com/apache/gravitino/pull/10673

   ### What changes were proposed in this pull request?
   
   Split the `ExpiredJwtException` / `BadJWTException` catch blocks in 
`StaticSignKeyValidator` and `JwksTokenValidator` to return the specific 
message `"Authentication token is expired"` instead of the generic `"JWT parse 
error"` / `"JWKS JWT validation error"`.
   
   Also adds regression tests (`testValidateExpiredTokenHasCorrectMessage`) in 
both test classes to guard against the message regressing.
   
   ### Why are the changes needed?
   
   Clients receiving a `401 Unauthorized` had no way to distinguish an expired 
token from a malformed or wrongly-signed token. An actionable error message 
lets clients know they should refresh/re-authenticate rather than debug a 
configuration issue.
   
   Fix: #10672
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes — the `401 Unauthorized` error message for an expired JWT changes from 
`"JWT parse error"` (static key) or `"JWKS JWT validation error"` (JWKS) to 
`"Authentication token is expired"`.
   
   ### How was this patch tested?
   
   - Added `testValidateExpiredTokenHasCorrectMessage` to 
`TestStaticSignKeyValidator` and `TestJwksTokenValidator`.
   - All existing and new unit tests pass (`./gradlew :server-common:test`).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to