Skip to content

Spring JDBC session not working after adding jackson support to http session serialization/Deserialization #1810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vkatoch2000 opened this issue Mar 25, 2021 · 3 comments
Assignees
Labels
type: bug A general bug

Comments

@vkatoch2000
Copy link

vkatoch2000 commented Mar 25, 2021

I Have logged this ticket earlier regarding the issue with the spring JDBC session deserialization after spring upgrade
#1805
They recommend it to use Jackson support to Spring JDBC HTTP session

I have create object mapper like :
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new CoreJackson2Module());
objectMapper.registerModules(SecurityJackson2Modules.getModules(loader));
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.addMixIn(DefaultOAuth2ClientContext.class, DefaultOAuth2ClientContextMixIn.class);

used this objectMapper for deserialization and serialization set it to JdbcIndexedSessionRepository conversion service.

DefaultOAuth2ClientContextMixIn create custom mixin :
public interface DefaultOAuth2ClientContextMixIn {

@JsonTypeInfo(defaultImpl = DefaultOAuth2AccessToken.class, use = JsonTypeInfo.Id.NONE)
OAuth2AccessToken getAccessToken();

@JsonTypeInfo(defaultImpl = DefaultAccessTokenRequest.class, use = JsonTypeInfo.Id.NONE)
AccessTokenRequest getAccessTokenRequest();

}
Getting error

com.fasterxml.jackson.databind.JsonMappingException: The class with com.sun.proxy.$Proxy344 and name of com.sun.proxy.$Proxy344 is not in the allowlist. If you believe this class is safe to deserialize, please provide an explicit mapping using Jackson annotations or by providing a Mixin. If the serialization is only done by a trusted source, you can also enable default typing. See spring-projects/spring-security#4370 for details (through reference chain: org.springframework.security.oauth2.client.DefaultOAuth2ClientContext["accessTokenRequest"])

Wrapped by: org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [UPDATE SPRING_SESSION_ATTRIBUTES SET ATTRIBUTE_BYTES = ? WHERE SESSION_PRIMARY_ID = ? AND ATTRIBUTE_NAME = ?]; ERROR: null value in column "attribute_bytes" violates not-null constraint
Detail: Failing row contains (f12d0737-815c-4b4d-8c8b-780ed8a171aa, scopedTarget.oauth2ClientContext, null).; nested exception is org.postgresql.util.PSQLException: ERROR: null value in column "attribute_bytes" violates not-null constraint

any clue what's wrong here?

@vkatoch2000 vkatoch2000 added status: waiting-for-triage An issue we've not yet triaged type: bug A general bug labels Mar 25, 2021
@eleftherias eleftherias self-assigned this Jul 23, 2021
@eleftherias
Copy link
Contributor

Thanks for reaching out @vkatoch2000.
It looks like you are using the deprecated spring-security-oauth project.

Please upgrade to the OAuth2 support provided by Spring Security. You may find this migration guide to be useful.

If you still have issues once you have upgraded feel free to reach out to us.

@eleftherias eleftherias added status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 23, 2021
@spring-projects-issues
Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Jul 30, 2021
@spring-projects-issues
Copy link

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

@spring-projects-issues spring-projects-issues removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue labels Aug 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants