spring-projects / spring-projects/spring-security

OAuth2ClientJacksonModule is missing allowIfSubType for URL and Instant

Open
#19,241 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage type: bug
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

Describe the bug
setup a spring mvc app with oauth2Login and redis session. When trying to login with any OIDC / OAuth 2 provider, after redirecting back to the app, it throws an error.

org.springframework.data.redis.serializer.SerializationException: Could not read JSON: Could not resolve type id 'java.net.URL' as a subtype of java.lang.Object: Configured PolymorphicTypeValidator (of type tools.jackson.databind.jsontype.BasicPolymorphicTypeValidator) denied resolution
at [Source: REDACTED (StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION disabled); byte offset: #1982] (through reference chain: org.springframework.security.core.context.SecurityContextImpl["authentication"]->org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken["principal"]->org.springframework.security.oauth2.core.oidc.user.DefaultOidcUser["authorities"]->java.util.HashSet[0]->org.springframework.security.oauth2.core.oidc.user.OidcUserAuthority["idToken"]->org.springframework.security.oauth2.core.oidc.OidcIdToken["claims"]->java.util.LinkedHashMap["iss"])
at org.springframework.data.redis.serializer.JacksonJsonRedisSerializer.deserialize(JacksonJsonRedisSerializer.java:143)

org.springframework.data.redis.serializer.SerializationException: Could not read JSON: Could not resolve type id 'java.time.Instant' as a subtype of java.lang.Object: Configured PolymorphicTypeValidator (of type tools.jackson.databind.jsontype.BasicPolymorphicTypeValidator) denied resolution
at [Source: REDACTED (StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION disabled); byte offset: #2435] (through reference chain: org.springframework.security.core.context.SecurityContextImpl["authentication"]->org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken["principal"]->org.springframework.security.oauth2.core.oidc.user.DefaultOidcUser["authorities"]->java.util.HashSet[0]->org.springframework.security.oauth2.core.oidc.user.OidcUserAuthority["idToken"]->org.springframework.security.oauth2.core.oidc.OidcIdToken["claims"]->java.util.LinkedHashMap["exp"])
at org.springframework.data.redis.serializer.JacksonJsonRedisSerializer.deserialize(JacksonJsonRedisSerializer.java:143)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate OAuth2ClientJacksonModule and inspect how subtype permissions are configured for claims. Reproduce the OAuth2/OIDC login with Redis-backed sessions, then verify that serialized URL and Instant claims can be deserialized without the PolymorphicTypeValidator errors shown in the report.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, redis, spring
Domain
authentication, backend, security
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.