Class SessionConfiguration

java.lang.Object
com.irurueta.authserver.bff.infrastructure.session.SessionConfiguration

@Configuration(proxyBeanMethods=false) public class SessionConfiguration extends Object
Names the cookie of the HTTP session of the BFF with the __Host- prefix. The session itself is stored in PostgreSQL by Spring Session JDBC (table spring_session, owned by the Flyway migration V300 of this module), which Spring Boot auto-configures from spring-boot-starter-session-jdbc.

There is deliberately no @EnableJdbcHttpSession: that annotation switches Spring Boot's session auto-configuration off, and with it every spring.session.* property (for example spring.session.jdbc.initialize-schema: never, which keeps the schema in Flyway's hands, or spring.session.timeout). The session holds the OAuth2 tokens of the user (the authorized client), which therefore never reach the browser; the cookie is only a handle to them.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final String
    Name of the session cookie; the __Host- prefix makes browsers require Secure, Path=/ and no Domain.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) org.springframework.session.web.http.CookieSerializer
    Builds the serializer of the session cookie: Secure, HttpOnly, SameSite=Lax, path / and no domain, which is exactly what the __Host- prefix demands (the browser rejects the cookie otherwise).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • SessionConfiguration

      public SessionConfiguration()
  • Method Details

    • cookieSerializer

      @Bean org.springframework.session.web.http.CookieSerializer cookieSerializer()
      Builds the serializer of the session cookie: Secure, HttpOnly, SameSite=Lax, path / and no domain, which is exactly what the __Host- prefix demands (the browser rejects the cookie otherwise).
      Returns:
      the cookie serializer.