jerqi commented on code in PR #8049:
URL: https://github.com/apache/gravitino/pull/8049#discussion_r2271955655
##########
server-common/src/main/java/org/apache/gravitino/server/authentication/JwksTokenValidator.java:
##########
@@ -147,23 +147,19 @@ private JWKSource<SecurityContext> createJwkSource()
throws Exception {
}
}
- /** Extracts the principal from the validated JWT claims using configured
field or fallbacks. */
+ /** Extracts the principal from the validated JWT claims using configured
field(s). */
private String extractPrincipal(JWTClaimsSet validatedClaims) {
- // Try the configured principal field first
+ // Try the principal field(s) one by one in order
if (StringUtils.isNotBlank(principalField)) {
- String principal = (String) validatedClaims.getClaim(principalField);
- if (principal != null) {
- return principal;
- }
- }
-
- // Fallback to common user identity fields
- // TODO: Consider making this configurable
- String[] fallbackFields = {"unique_name", "upn", "email",
"preferred_username", "sub"};
- for (String field : fallbackFields) {
- String principal = (String) validatedClaims.getClaim(field);
- if (principal != null) {
- return principal;
+ String[] configuredFields = principalField.split(",");
Review Comment:
public ConfigEntry<List<T>> toSequence() {}
--
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]