Skip to content

Add regression test for FactorGrantedAuthority Jackson support - #19594

Open
jyx-07 wants to merge 1 commit into
spring-projects:mainfrom
jyx-07:gh-18771
Open

Add regression test for FactorGrantedAuthority Jackson support#19594
jyx-07 wants to merge 1 commit into
spring-projects:mainfrom
jyx-07:gh-18771

Conversation

@jyx-07

@jyx-07 jyx-07 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

#18771 reports that JdbcOAuth2AuthorizationService fails to deserialize FactorGrantedAuthority because of a missing Jackson mixin, and @k6leung validated a FactorGrantedAuthorityMixin + module as a workaround.

Investigating on current main, FactorGrantedAuthorityMixin already exists and is already registered in both CoreJackson2Module and CoreJacksonModule — it was added together with FactorGrantedAuthority itself, before this issue was filed. A from-scratch reproduction (round-tripping a UsernamePasswordAuthenticationToken whose authorities include a FactorGrantedAuthority, through the exact ObjectMapper/JsonMapper setup JdbcOAuth2AuthorizationService builds internally) already passes on main, so adding another mixin would just duplicate existing plumbing.

Rather than duplicate that fix, this PR adds a regression test — to OAuth2AuthorizationServerJackson2ModuleTests and its Jackson 3 counterpart OAuth2AuthorizationServerJacksonModuleTests — that locks in the already-working round trip so a future regression here is caught before release. I verified the test is non-tautological by temporarily reverting the mixin registration locally and confirming both new tests fail without it.

I'll comment on #18771 to let @k6leung know the underlying mixin is already fixed on main.

Test plan

  • Added readValueWhenOAuth2AuthorizationAttributesWithFactorGrantedAuthorityThenSuccess to both OAuth2AuthorizationServerJackson2ModuleTests and OAuth2AuthorizationServerJacksonModuleTests.
  • Verified the new tests fail if the FactorGrantedAuthorityMixin registration is reverted, confirming they're not tautological.
  • ./gradlew :spring-security-oauth2-authorization-server:test — full module suite passes.

Closes gh-18771

Add a test to OAuth2AuthorizationServerJackson2ModuleTests and its
Jackson 3 counterpart that round-trips an OAuth2Authorization's
Principal attribute when the principal's authorities include a
FactorGrantedAuthority, using the same ObjectMapper/JsonMapper setup
JdbcOAuth2AuthorizationService builds internally.

FactorGrantedAuthorityMixin already exists and is registered in
CoreJackson2Module/CoreJacksonModule (added together with
FactorGrantedAuthority itself), so this round trip already succeeds
on main. This test only locks in that existing, previously
uncovered behavior so a future regression is caught before release.

Closes spring-projectsgh-18771

Signed-off-by: jyx-07 <s25069@gsm.hs.kr>
@k6leung

k6leung commented Aug 24, 2026

Copy link
Copy Markdown

Acknowledged, I will update my test project to springboot 4.1.0 and retest the native image within the week, thanks for the heads-up, @jyx-07.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spring Security Authorization Server is missing the Jackson Mixin for FactorGrantedAuthority

3 participants