Add allowIfSubType for URL and Instant in OAuth2ClientJacksonModule - #19243
qwerty7878 wants to merge 2 commits 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 Map<String, Object>, so a URL can appear in any map-valued payload rather than only in the OAuth2 modules. And since SecurityJacksonModules passes a single shared builder to every SecurityJacksonModule, adding it to CoreJacksonModule covers the OAuth2 path as well. I've moved allowIfSubType(URL.class) there and dropped the Instant entry since it's already present. The OAuth2 test is kept as a regression test for the originally reported scenario, and it passes with the fix only in core. On the Jackson 2 / Jackson 3 gap: I compared AllowlistTypeIdResolver.ALLOWLIST_CLASS_NAMES against CoreJacksonModule entry by entry. java.net.URL is the only one present in the Jackson 2 allowlist and missing from the Jackson 3 one, so this change should close it. |
|
@jzheaux we're also hitting this issue. what is missing to get this PR merged? |
Signed-off-by: hyeonjune <142138946+qwerty7878@users.noreply.github.com>
1302efc to
931e2ee
Compare
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