-
Notifications
You must be signed in to change notification settings - Fork 35
Error creating bean 'scopedTarget.accessTokenRequest' when using Spring Security OAuth and JacksonMongoSessionConverter #1
Comments
Hello, Spring Session : 1.3.2.RELEASE Here is my understanding of the problem :
|
Per http://projects.spring.io/spring-session-data-mongodb/, Spring Session MongoDB currently supported versions only includes 2.0, which requires Spring Boot 2.0 as well. As for OAuth support, you'll have to check with the Spring Security team on covering that piece. |
@gregturn Indeed. Please note, that the problem we hit, is not specific to OAuth support. |
Then you should properly close this issue and open one against against https://github.com/spring-projects/spring-sesssion. |
I'm very sorry @gonzalad, I didn't read carefully your first comment : After some thinking, it appears clear to me now, that the fact that the RequestContextFilter closes the scope before the SessionRepositoryFilter store the session is not the real problem (and is not a problem at all). JdkMongoSessionConverter using java serialization AND the spring framework allowing the serialisation of BeanFactory based proxies (because DefaultListableBeanFactory is serialized only by id) => it does exactly that and it works JacksonMongoSessionConverter is just unable to correctly identified the special case of a proxy as it only serialize object's fields @gregturn : Moreover, the documentation does state that JacksonMongoSessionConverter doesn't store correctly some Spring Security objects This affects Spring Session 1.x at least. I think that for this issue :
|
Spring Security has instituted "white listing" to insulate from Jackson serializing/deserializing unacceptable types and hacking the security paradigm. Spring Session MongoDB leverages this when using it's Jackson-based solution. If you are able to update your project to Boot 2.0, then we can continue working on where the root of this issue is. Otherwise, you may have to settle for MongoDB not being a session option with Boot 1.x. |
@gregturn for example OAuth2Authentication class has no default constructor. So Jackson can't serialize/deserialize that instance from the MongoSession in JacksonMongoSessionConverter. And yes, we have to add additional mixin for the OAuth2Authentication to the ObjectMapper as it defined for MongoSession and HashMap. |
Issue sounds twofold:
Both of these require coordination with the Spring Security team. |
Duplicates spring-projects/spring-security#4886 |
@gregturn, just to be more precise about your previous comment for others users :
MongoDB is sill an option in Spring Security OAuth2 / Boot 1.x context, but users do need to configure a JdkMongoSessionConverter |
Spring Session MongoDB 2.0 only supports Spring Boot 2.0+. Version 1.3 was discontinued, the version that works with Boot 1.5. Any other configuration is not supported. |
I'm using
I have the issue only with JacksonMongoSessionConverter, not with JdkMongoSessionConverter.
I use the following Spring Session config :
For OAuth setup it's a Spring Boot OAuth2 Client setup similar to https://spring.io/guides/tutorials/spring-boot-oauth2/#_social_login_simple (adapted for my own OAuth Authorization Server)
When accessing the main page of my app I get a :
I thinks this issue is due because Spring Security OAuth relies on requestScoped or sessionScoped bean, and SessionRepositoryFilter is executed outside of RequestContextFilter, and JacksonMongoSessionConverter tries to access a session scoped bean but RequestContextHolder..currentRequestAttributes isn't anymore available.
Complete stack:
The text was updated successfully, but these errors were encountered: