Add Partitioned Cookie Support to DefaultCookieSerializer

Closes gh-2787
This commit is contained in:
Marcus Hert Da Coregio
2024-06-13 16:29:03 -03:00
parent 60efefd948
commit 5dc161d75d
3 changed files with 24 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2021 the original author or authors.
* Copyright 2014-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -86,6 +86,8 @@ public class DefaultCookieSerializer implements CookieSerializer {
private String sameSite = "Lax";
private boolean partitioned;
/*
* @see
* org.springframework.session.web.http.CookieSerializer#readCookieValues(jakarta.
@@ -153,6 +155,9 @@ public class DefaultCookieSerializer implements CookieSerializer {
if (this.sameSite != null) {
sb.append("; SameSite=").append(this.sameSite);
}
if (this.partitioned) {
sb.append("; Partitioned");
}
response.addHeader("Set-Cookie", sb.toString());
}
@@ -444,4 +449,12 @@ public class DefaultCookieSerializer implements CookieSerializer {
return this.rememberMeRequestAttribute;
}
/**
* Allows defining whether the generated cookie carries the Partitioned attribute
* @since 3.4
*/
public void setPartitioned(boolean partitioned) {
this.partitioned = partitioned;
}
}