From 3293f07949752a0260d10eaca2f0ac19ce26b848 Mon Sep 17 00:00:00 2001 From: chanbinme Date: Sun, 15 Jun 2025 00:58:29 +0900 Subject: [PATCH] Remove authoritiesClaimName Field This commit simplfies the logic in JwtGrantedAuthoritiesConverter to no longer need the authoritiesClaimName field. Signed-off-by: chanbinme --- .../authentication/JwtGrantedAuthoritiesConverter.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/authentication/JwtGrantedAuthoritiesConverter.java b/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/authentication/JwtGrantedAuthoritiesConverter.java index a0d1dc43a2..6ca21b2bdb 100644 --- a/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/authentication/JwtGrantedAuthoritiesConverter.java +++ b/oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/authentication/JwtGrantedAuthoritiesConverter.java @@ -53,7 +53,7 @@ public final class JwtGrantedAuthoritiesConverter implements Converter authoritiesClaimNames = WELL_KNOWN_AUTHORITIES_CLAIM_NAMES; /** * Extract {@link GrantedAuthority}s from the given {@link Jwt}. @@ -102,14 +102,11 @@ public void setAuthoritiesClaimDelimiter(String authoritiesClaimDelimiter) { */ public void setAuthoritiesClaimName(String authoritiesClaimName) { Assert.hasText(authoritiesClaimName, "authoritiesClaimName cannot be empty"); - this.authoritiesClaimName = authoritiesClaimName; + this.authoritiesClaimNames = Collections.singletonList(authoritiesClaimName); } private String getAuthoritiesClaimName(Jwt jwt) { - if (this.authoritiesClaimName != null) { - return this.authoritiesClaimName; - } - for (String claimName : WELL_KNOWN_AUTHORITIES_CLAIM_NAMES) { + for (String claimName : this.authoritiesClaimNames) { if (jwt.hasClaim(claimName)) { return claimName; }