JDBC session store: InvalidClassException on SecurityContextImpl after Spring Security upgrade (similar to #181, but for SPRING_SESSION_ATTRIBUTES)

Abierto
#4,189 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
java, spring, sql

Línea de trabajo

Start with UaaJdbcSessionConfig and the SPRING_SESSION_ATTRIBUTES.ATTRIBUTE_BYTES serialization path, then compare the JSON-based UaaTokenStore approach from #181. Reproduce the rolling-upgrade failure with an existing JDBC session, and confirm that the session conversion service or serializer can read both SecurityContextImpl versions. Done means old and new sessions remain usable across the upgrade and a regression test covers both serialization directions.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

With servlet.session-store: database, sessions are stored by Spring Session JDBC using JDK serialization. After upgrading UAA to a version with a different Spring Security minor, any request carrying an existing JSESSIONID fails:

  at org.springframework.session.jdbc.JdbcIndexedSessionRepository.deserialize
  at ...JdbcSession.getAttribute
  at ...HttpSessionSecurityContextRepository.loadContext
Caused by: java.io.InvalidClassException: org.springframework.security.core.context.SecurityContextImpl;
  local class incompatible: stream classdesc serialVersionUID = 580, local class serialVersionUID = 620

The same happens in both directions during a rolling update. The Thymeleaf error template also reads the session, so the error page fails to render too (TemplateOutputException).

#181 fixed this for oauth_code by storing JSON (UaaTokenStore). SPRING_SESSION_ATTRIBUTES.ATTRIBUTE_BYTES has the same problem. UaaJdbcSessionConfig does not configure a springSessionConversionService or any serializer.

UAA Version - 78.9.0

Full log -

org.thymeleaf.exceptions.TemplateOutputException: An error happened during template rendering
	...
Caused by: org.springframework.core.convert.ConversionFailedException: Failed to convert from type [byte[]] to type [java.lang.Object] for value [{...}]
	...
	at org.springframework.session.jdbc.JdbcIndexedSessionRepository.deserialize(JdbcIndexedSessionRepository.java:689)
	at org.springframework.session.jdbc.JdbcIndexedSessionRepository$JdbcSession.getAttribute(JdbcIndexedSessionRepository.java:801)
	at org.springframework.session.web.http.HttpSessionAdapter.getAttribute(HttpSessionAdapter.java:102)
	at org.springframework.security.web.context.HttpSessionSecurityContextRepository.readSecurityContextFromSession(HttpSessionSecurityContextRepository.java:212)
	at org.springframework.security.web.context.HttpSessionSecurityContextRepository.loadContext(HttpSessionSecurityContextRepository.java:126)
	...
Caused by: org.springframework.core.serializer.support.SerializationFailedException: Failed to deserialize payload. Is the byte array a result of corresponding serialization for DefaultDeserializer?
	...
Caused by: java.io.InvalidClassException: org.springframework.security.core.context.SecurityContextImpl; local class incompatible: stream classdesc serialVersionUID = 580, local class serialVersionUID = 620```
Lenguaje dominante
Java
Estrellas
1.6k
Forks
847
Merge medio
2 d 1 h
PR fusionados (30 d)
48

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de cloudfoundry/uaa

Todos los issues de cloudfoundry/uaa

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.