Skip to content

removeAuthorizationRequest of HttpSessionOAuth2AuthorizationRequestRepository always return null #12654

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
Y-k-Y opened this issue Feb 10, 2023 · 5 comments
Assignees
Labels
for: stackoverflow A question that's better suited to stackoverflow.com

Comments

@Y-k-Y
Copy link

Y-k-Y commented Feb 10, 2023

Describe the bug
removeAuthorizationRequest method of HttpSessionOAuth2AuthorizationRequestRepository always return null which cause OAuth2AuthenticationException when using it with GenericJackson2JsonRedisSerializer

To Reproduce

  1. Configure project included below dependencies
plugins {
    id 'java'
    id 'org.springframework.boot' version '2.7.8'
    id 'io.spring.dependency-management' version '1.0.15.RELEASE'
}

sourceCompatibility = '11'

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
    implementation 'org.springframework.boot:spring-boot-starter-security'
    implementation 'org.springframework.boot:spring-boot-starter-data-redis'
    implementation('org.springframework.session:spring-session-data-redis') {
        exclude group: 'org.springframework.data', module: 'spring-data-redis'
    }
}
  1. Configure redis to use Generic2Jackson2JsonRedisSerializer so that session value can be stored as json format
  2. Try to authenticate through oauth2 protocol

Expected behavior
It should be return appropriate request value no matter what format we use.

Sample
Look around this Sample and don't forget to configure oauth2 properties with yours

@ilyako87
Copy link

ilyako87 commented Jul 7, 2023

@Y-k-Y Hello, have you been able to solve this problem?
I have a very similar problem, but with Spring Boot 3.

@Y-k-Y
Copy link
Author

Y-k-Y commented Jul 10, 2023

@ilyako87 Unfortunately i couldn't solve this problem.
I had to use the default serializer. If you encounter similar issue with mine then i guess it didn't fixed yet.
Let me know if you solve your problem i also want to know how to solve this one as well.

@wylswz
Copy link

wylswz commented Feb 1, 2024

I came across a similar issue today but it's nothing to do with serializer. I was debugging the application on a remote server with https disable. However the cookie was configured to be secure, thus not sent to the server, then it kept creating new sessions.

@sjohnr
Copy link
Member

sjohnr commented Jun 5, 2024

Thanks for reaching out @Y-k-Y! Apologies that this issue was not responded to for a long time.

Thank you for providing a sample. It appears that you are not configuring the ObjectMapper for Redis per the documentation. I believe it would look like this (which works when I change your sample). I don't think you need the RedisTemplate @Bean in your sample to make Spring Session work.

@sjohnr sjohnr closed this as completed Jun 5, 2024
@sjohnr sjohnr added for: stackoverflow A question that's better suited to stackoverflow.com and removed status: waiting-for-triage An issue we've not yet triaged type: bug A general bug labels Jun 5, 2024
@sjohnr sjohnr self-assigned this Jun 5, 2024
@Y-k-Y
Copy link
Author

Y-k-Y commented Jun 7, 2024

Thank you @sjohnr! Yes i can confirm that it resolves the issue. I should configure ObjectMapper for serializer not RedisTemplate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: stackoverflow A question that's better suited to stackoverflow.com
Projects
None yet
Development

No branches or pull requests

4 participants