Skip to content

Commit a0f3f0d

Browse files
authored
JWTBroker: move error message (#2330)
This change moves the `LOGGER.error` call when a token cannot be verified from `verify()` to `generateFromToken()`. On the token generation path, this should be a no-op; however, on the authentication path, this log message was excessive, especially when using mixed authentication since a failure to decode a token is perfectly normal when the token is from an external IDP.
1 parent 6647374 commit a0f3f0d

File tree

1 file changed

+3
-2
lines changed
  • runtime/service/src/main/java/org/apache/polaris/service/auth

1 file changed

+3
-2
lines changed

runtime/service/src/main/java/org/apache/polaris/service/auth/JWTBroker.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ public String getScope() {
8989
};
9090

9191
} catch (JWTVerificationException e) {
92-
LOGGER.error("Failed to verify the token with error", e);
93-
throw new NotAuthorizedException("Failed to verify the token");
92+
throw (NotAuthorizedException)
93+
new NotAuthorizedException("Failed to verify the token").initCause(e);
9494
}
9595
}
9696

@@ -115,6 +115,7 @@ public TokenResponse generateFromToken(
115115
try {
116116
decodedToken = verify(subjectToken);
117117
} catch (NotAuthorizedException e) {
118+
LOGGER.error("Failed to verify the token", e.getCause());
118119
return new TokenResponse(Error.invalid_client);
119120
}
120121
EntityResult principalLookup =

0 commit comments

Comments
 (0)