`CoreJackson2Module` has no mixin for `OneTimeTokenAuthentication`
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 77/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- authentication, backend
Research direction
Read CoreJackson2Module alongside CoreJacksonModule to compare their mixin registrations, then inspect OneTimeTokenAuthenticationTests and the Jackson 2 module tests. Add coverage for serializing and deserializing OneTimeTokenAuthentication through SecurityJackson2Modules; done means the Jackson 2 round trip succeeds, including the allowlist check.
Written by the indexing model from the issue text.
Description
Describe the bug
gh-18096 added Jackson support for one-time-token authentication for 7.1, but only the Jackson 3 CoreJacksonModule registers a mixin for OneTimeTokenAuthentication; the Jackson 2 CoreJackson2Module registers one for the deprecated OneTimeTokenAuthenticationToken only. Since 7.0, OneTimeTokenAuthenticationProvider and OneTimeTokenReactiveAuthenticationManager produce OneTimeTokenAuthentication, so a SecurityContext from a one-time-token login cannot be serialized with SecurityJackson2Modules, which is still the setup of applications that keep Jackson 2 for session serialization in 7.x.
To Reproduce
ObjectMapper mapper = new ObjectMapper();
mapper.registerModules(SecurityJackson2Modules.getModules(getClass().getClassLoader()));
OneTimeTokenAuthentication authentication = new OneTimeTokenAuthentication("principal",
AuthorityUtils.createAuthorityList("ROLE_USER"));
byte[] serialized = mapper.writeValueAsBytes(authentication);
mapper.readValue(serialized, OneTimeTokenAuthentication.class);
Deserialization fails: OneTimeTokenAuthentication is not in the allowlist and has no mixin. The same round trip with SecurityJacksonModules and a Jackson 3 JsonMapper passes (OneTimeTokenAuthenticationTests).
Expected behavior
CoreJackson2Module registers a mixin for OneTimeTokenAuthentication, like CoreJacksonModule does, so that both Jackson generations can serialize what the one-time-token login produces.
Sample
Branch with the mixin (a copy of the Jackson 3 one, deprecated for removal like the rest of jackson2) and a Jackson 2 round-trip test next to the existing Jackson 3 one: https://github.com/spring-projects/spring-security/compare/main...sharanggupta:spring-security:gh-ott-authentication-jackson2-mixin. Happy to open the PR.
- Dominant language
- Java
- Stars
- 9.7k
- Forks
- 6.4k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 37
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from spring-projects/spring-security
-
OidcUserInfo builder shoud accept Instant for the updateAt methodPossibly taken @KaranCodez claimed this today. Openstatus: waiting-for-triage type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
spring-projects/spring-security#20013 ·
Maintainers usually reply within 1 day
-
status: waiting-for-triage
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
spring-projects/spring-security#19996 ·
Maintainers usually reply within 1 day
-
status: waiting-for-triage type: enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
spring-projects/spring-security#19995 ·
Maintainers usually reply within 1 day
-
status: waiting-for-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
spring-projects/spring-security#19984 ·
Maintainers usually reply within 1 day
-
Spring-security-7.1.xsd schema validates request-matcher incorrectlyPossibly taken @suryakant-source claimed this 10 days ago. Openstatus: waiting-for-triage type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
spring-projects/spring-security#19981 · 1 comment ·
Maintainers usually reply within 1 day
All issues in spring-projects/spring-security
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
a2aproject/a2a-java#1275 ·
Maintainers usually reply within 1 day
-
module/ftp Type/Bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ballerina-platform/ballerina-library#9476 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
anwilli5/coin-collection-android-US#515 ·
Maintainers usually reply within 1 day
-
status: waiting-for-triage type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
spring-projects/spring-integration#11654 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 Under an hour Newbie friendliness 70/100
Vakore/ZappierGames#248 ·