spring-projects / spring-boot

Spring Boot helps you to create Spring-powered, production-grade applications and services with absolute minimum fuss.
https://spring.io/projects/spring-boot
Apache License 2.0
75.13k stars 40.68k forks source link

Add support for partitioned cookies #42307

Closed miskr-instructure closed 1 month ago

miskr-instructure commented 1 month ago

Since the fix of https://github.com/spring-projects/spring-session/issues/2787 the DefaultCookieSerializer of spring session now supports the partitioned attribute. However that attribute cannot be set via configuration, only by providing a custom CookieSerializer Bean.

This application.yml does not work as one would intuitively expect:

server:
  servlet:
    session:
      cookie:
        same-site: 'none'
        partitioned: 'true'  # <-- no effect
        secure: 'true'       # <-- also no effect?

... it seems it's only possible to set the new value by providing a custom @Bean:

@Configuration
class CustomCookieSerializerConfig {
  @Bean
  CookieSerializer cookieSerializer() {
    var cookieSerializer = new DefaultCookieSerializer();
    cookieSerializer.setSameSite("None");
    cookieSerializer.setPartitioned(true);
    cookieSerializer.setUseSecureCookie(true);
    return cookieSerializer;
  }
}

The likely cause is missing implementation in org.springframework.session.config.annotation.web.http.SpringHttpSessionConfiguration.createDefaultCookieSerializer()

Regarding affected versions:

philwebb commented 1 month ago

We don't currently have support for partitioned, but I'm surprised to see secure not working. Are you sure that's the case @miskr-instructure?

philwebb commented 1 month ago

Closing in favor of PR #42316. Thanks @nosan!