-
Notifications
You must be signed in to change notification settings - Fork 1.1k
bug(spring-session-mongo) HttpSessionRequestCache tries to deserialize SPRING_SECURITY_SAVED_REQUEST but fails #686
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
Labels
for: stack-overflow
A question that's better suited to stackoverflow.com
Comments
I'm having the same issue, ver. 1.3.0.RELEASE |
@leon @mkopylec There are two options to address this issue:
|
Thanks @vpavic, that should fix the problem. |
@mkopylec Thanks for feedback, closing as answered. |
To those finding this here is what you need to do explicitly Add a import com.fasterxml.jackson.databind.Module;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.jackson2.SecurityJackson2Modules;
import org.springframework.session.data.mongo.AbstractMongoSessionConverter;
import org.springframework.session.data.mongo.JacksonMongoSessionConverter;
import org.springframework.session.data.mongo.config.annotation.web.http.EnableMongoHttpSession;
import java.util.List;
@Configuration
@EnableMongoHttpSession
public class SessionConfig {
/**
* Register security jackson modules so that jackson can convert the session including the spring security classes
*/
@Bean
public AbstractMongoSessionConverter mongoSessionConverter() {
List<Module> securityModules = SecurityJackson2Modules.getModules(getClass().getClassLoader());
return new JacksonMongoSessionConverter(securityModules);
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When using spring-session-mongo I've using spring security and a UserDetails Service which should be persisted into the session.
I'm currently getting multiple problems when trying to deserialize the session.
caused by
on line 71, where it tries to cast the deserialized map into a
SavedRequest
I've written a couple of test where you can try it out.
https://github.com/leon/spring-session/blob/mongo-cannot-handle-saved-request/spring-session/src/test/java/org/springframework/session/data/mongo/JacksonMongoSessionConverterTest.java#L92
I then have the same problem with the UserDetails class which gets serialized as the principal.
Am I doing something wrong, or is this a bug / feature that is missing?
The text was updated successfully, but these errors were encountered: