Add allowIfSubType for URL and Instant in OAuth2ClientJacksonModule - #19243
Add allowIfSubType for URL and Instant in OAuth2ClientJacksonModule #19243qwerty7878 wants to merge 1 commit into
Conversation
809a078 to
fd660f1
Compare
|
I was hit by this problem as well. The Jackson 2 modules already handle this properly in @qwerty7878 I think that the right fix would be to do this in the Maybe someone from the spring-security team can also look into this. Currently, there is a gap between the Jackson 2 and Jackson 3 support |
Signed-off-by: hyeonjune <annhj980@naver.com>
fd660f1 to
adf2a17
Compare
|
Thanks @filiphr, that makes sense. The failure happens on OidcIdToken#getClaims(), which is a I've moved allowIfSubType(URL.class) there and dropped the Instant entry On the Jackson 2 / Jackson 3 gap: I compared |
Fixes gh-19241
Problem
Deserializing an
OAuth2AuthenticationTokenfrom a Redis session failswith a
SerializationException, becauseOidcIdTokenstoresissas ajava.net.URLinside its claims map and the configuredPolymorphicTypeValidatordenies it.java.net.URLis present in the Jackson 2 allowlist(
AllowlistTypeIdResolver.ALLOWLIST_CLASS_NAMES) but missing from theJackson 3 modules.
Fix
Added
allowIfSubType(URL.class)toCoreJacksonModule.SecurityJacksonModulespasses a single shared builder to everySecurityJacksonModule, so the entry applies to the OAuth2 modules aswell.
Tests
deserializeWhenMapContainsUrlThenDeserializesinSecurityJacksonModulesTests— aMapvalue of typeURLround-tripsdeserializeWhenClaimsContainUrlThenDeserializesinOAuth2AuthenticationTokenMixinTests— regression test for theoriginally reported scenario