Skip to content

Add support for partitioned cookies #42307

Not planned
Not planned
@miskr-instructure

Description

@miskr-instructure

Since the fix of spring-projects/spring-session#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:

  • "server.servlet.session.cookie.secure" doesn't work in spring boot 3.3.x (and probably never has based on git blame)
  • the partitioned feature will be a new one in spring boot 3.4.x which is not released yet (but it'd be nice if it worked by the time it goes GA)

Activity

philwebb

philwebb commented on Sep 13, 2024

@philwebb
Member

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?

changed the title [-]Cannot configure "secure" and "partitioned" attributes via "server.servlet.session.cookie"[/-] [+]Add support for partitioned cookies[/+] on Sep 13, 2024
added this to the 3.4.x milestone on Sep 13, 2024
added a commit that references this issue on Sep 15, 2024
philwebb

philwebb commented on Sep 15, 2024

@philwebb
Member

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

added
status: supersededAn issue that has been superseded by another
and removed on Sep 15, 2024
removed this from the 3.4.x milestone on Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: supersededAn issue that has been superseded by another

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @philwebb@spring-projects-issues@miskr-instructure

        Issue actions

          Add support for partitioned cookies · Issue #42307 · spring-projects/spring-boot