Description
Summary
Error in serialization of non serializable SAML Requests prevents authentication if session is stored in database.
If spring-session-jdbc (= session is stored in database) is configured / enabled, an exception is thrown during issuing a SAML AuthN request. As per documentation,
spring security saml2 stores the Saml2AuthenticationRequest (either Saml2PostAuthenticationRequest or Saml2RedirectAuthenticationRequest) in the session before
actually sending them to the ipd (asserting party).
Now spring-session jdbc uses object serialization to store the session-data in the db. The Saml2AuthenticationRequests are not serializable and hence an exception
is thrown, preventing successful authentication.
Actual Behavior
Exception is thrown at org.springframework.core.serializer.DefaultSerializer.serialize
Expected Behavior
There should be no issue with saml2 when using jdbc session.
Supposed Solutions:
- make Saml2PostAuthenticationRequest and Saml2RedirectAuthenticationRequest serializable to allow default components to work
- alternatively open to subclassing and/or provide usable public constructor or factory method. This could then be used in a custom
Saml2AuthenticationRequestRepository
Configuration
spring boot with spring-session-jdbc spring-security-saml2
Version
spring boot 2.6.0 coming with spring-security-saml2-service-provider-5.6.0 and spring-session-jdbc-2.6.0