mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Honor authorities-claim-delimiter when set on its own
See gh-51619 Signed-off-by: JaeHyunAn <98042706+yyuneu@users.noreply.github.com>
This commit is contained in:
committed by
Andy Wilkinson
parent
b1e91c942e
commit
537c80dbb9
+5
@@ -265,6 +265,11 @@ class ReactiveOAuth2ResourceServerJwtConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@ConditionalOnProperty("spring.security.oauth2.resourceserver.jwt.authorities-claim-delimiter")
|
||||
static class OnAuthoritiesClaimDelimiter {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
@@ -257,6 +257,11 @@ class OAuth2ResourceServerJwtConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@ConditionalOnProperty("spring.security.oauth2.resourceserver.jwt.authorities-claim-delimiter")
|
||||
static class OnAuthoritiesClaimDelimiter {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -53,7 +53,7 @@ public final class JwtConverterCustomizationsArgumentsProvider implements Argume
|
||||
String principalClaimProperty = "spring.security.oauth2.resourceserver.jwt.principal-claim-name="
|
||||
+ customPrincipalClaim;
|
||||
String[] customPrefixProps = { jwkSetUriProperty, authorityPrefixProperty };
|
||||
String[] customDelimiterProps = { jwkSetUriProperty, authorityPrefixProperty, authoritiesDelimiterProperty };
|
||||
String[] customDelimiterProps = { jwkSetUriProperty, authoritiesDelimiterProperty };
|
||||
String[] customAuthoritiesClaimProps = { jwkSetUriProperty, authoritiesClaimProperty };
|
||||
String[] customPrincipalClaimProps = { jwkSetUriProperty, principalClaimProperty };
|
||||
String[] allJwtConverterProps = { jwkSetUriProperty, authorityPrefixProperty, authoritiesDelimiterProperty,
|
||||
@@ -84,7 +84,7 @@ public final class JwtConverterCustomizationsArgumentsProvider implements Argume
|
||||
Arguments.of(Named.named("Custom prefix for GrantedAuthority", customPrefixProps),
|
||||
noAuthoritiesCustomizationsJwt, subjectValue, customPrefixAuthorities),
|
||||
Arguments.of(Named.named("Custom delimiter for JWT scopes", customDelimiterProps),
|
||||
customAuthoritiesDelimiterJwt, subjectValue, customPrefixAuthorities),
|
||||
customAuthoritiesDelimiterJwt, subjectValue, defaultPrefixAuthorities),
|
||||
Arguments.of(Named.named("Custom JWT authority claim name", customAuthoritiesClaimProps),
|
||||
customAuthoritiesClaimJwt, subjectValue, defaultPrefixAuthorities),
|
||||
Arguments.of(Named.named("Custom JWT principal claim name", customPrincipalClaimProps),
|
||||
|
||||
+7
@@ -701,6 +701,13 @@ class ReactiveOAuth2ResourceServerAutoConfigurationTests {
|
||||
.run((context) -> assertThat(context).hasSingleBean(ReactiveJwtAuthenticationConverter.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldConfigureJwtConverterIfAuthoritiesClaimDelimiterIsSet() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("spring.security.oauth2.resourceserver.jwt.authorities-claim-delimiter=dummy")
|
||||
.run((context) -> assertThat(context).hasSingleBean(ReactiveJwtAuthenticationConverter.class));
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "{0}")
|
||||
@ArgumentsSource(JwtConverterCustomizationsArgumentsProvider.class)
|
||||
void autoConfigurationShouldConfigureResourceServerWithJwtConverterCustomizations(String[] properties, Jwt jwt,
|
||||
|
||||
+7
@@ -738,6 +738,13 @@ class OAuth2ResourceServerAutoConfigurationTests {
|
||||
.run((context) -> assertThat(context).hasSingleBean(JwtAuthenticationConverter.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldConfigureJwtConverterIfAuthoritiesClaimDelimiterIsSet() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("spring.security.oauth2.resourceserver.jwt.authorities-claim-delimiter=dummy")
|
||||
.run((context) -> assertThat(context).hasSingleBean(JwtAuthenticationConverter.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void jwtAuthenticationConverterByJwtConfigIsConditionalOnMissingBean() {
|
||||
String propertiesPrincipalClaim = "principal_from_properties";
|
||||
|
||||
Reference in New Issue
Block a user