Repository navigation
OAuth2 resource server ignores authorities-claim-delimiter when set on its own - #51619
Merged
wilkinsona merged 1 commit intoSep 8, 2026
Conversation
yyuneu
added a commit
to yyuneu/spring-boot
that referenced
this pull request
Sep 8, 2026
See spring-projectsgh-51619 Signed-off-by: JaeHyunAn <98042706+yyuneu@users.noreply.github.com>
yyuneu
force-pushed
the
fix/jwt-converter-authorities-claim-delimiter
branch
from
September 8, 2026 09:02
bc55619 to
a84919a
Compare
See spring-projectsgh-51619 Signed-off-by: JaeHyunAn <98042706+yyuneu@users.noreply.github.com>
wilkinsona
force-pushed
the
fix/jwt-converter-authorities-claim-delimiter
branch
from
September 8, 2026 15:40
a84919a to
537c80d
Compare
Member
|
Thank you, @yyuneu. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What happened?
Setting
spring.security.oauth2.resourceserver.jwt.authorities-claim-delimiterwithout any other JWT converter properties has no effect. For example, given a JWT with ascopeclaim ofread,writeand the following configuration:The resulting authentication has a single authority,
SCOPE_read,write, instead ofSCOPE_readandSCOPE_write. An authorization rule usinghasAuthority('SCOPE_read')therefore denies access.In both
OAuth2ResourceServerJwtConfigurationand its reactive counterpart,JwtConverterConfigurationis guarded byJwtConverterPropertiesCondition. ThisAnyNestedConditionchecks three properties:authority-prefixprincipal-claim-nameauthorities-claim-nameThe converter bean method also applies
authorities-claim-delimiter, but that property is missing from the condition. When it is the only converter property set, the condition does not match and Spring Boot does not configure a converter bean. Spring Security then uses its default converter, which splits the claim on a single space.Support for all four properties was added in #38105. The condition added as part of that change checks only three of them.
The existing "Custom delimiter for JWT scopes" test case did not catch this because it also set
authority-prefix, which satisfied the condition.What does this PR change?
Adds a nested condition for
authorities-claim-delimitertoJwtConverterPropertiesConditionin both the servlet and reactive configurations. Setting the delimiter alone now enables the converter configuration.Unset properties retain their defaults because
PropertyMapperskips null values. User-defined converter beans still take precedence through@ConditionalOnMissingBean.The delimiter is also missing from the corresponding conditions on
4.1.xandmain, where they live inJwtConverterConfiguration.PropertiesConditionandReactiveJwtConverterConfiguration.PropertiesCondition.Tests
shouldConfigureJwtConverterIfAuthoritiesClaimDelimiterIsSetto bothOAuth2ResourceServerAutoConfigurationTestsandReactiveOAuth2ResourceServerAutoConfigurationTests, following the existing tests for the other three properties.JwtConverterCustomizationsArgumentsProviderto set the delimiter without a custom authority prefix. It now expects the split scopes to use the defaultSCOPE_prefix.The new tests and the updated parameterized case fail without the fix. The parameterized case fails with
NoSuchBeanDefinitionExceptionbecause no converter bean is configured.:module:spring-boot-security-oauth2-resource-server:checkpasses with JDK 25.