File tree 3 files changed +24
-5
lines changed
main/java/org/springframework/session/web/http
test/java/org/springframework/session/web/http
spring-session-docs/modules/ROOT/pages 3 files changed +24
-5
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2014-2021 the original author or authors.
2
+ * Copyright 2014-2024 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -86,6 +86,8 @@ public class DefaultCookieSerializer implements CookieSerializer {
86
86
87
87
private String sameSite = "Lax" ;
88
88
89
+ private boolean partitioned ;
90
+
89
91
/*
90
92
* @see
91
93
* org.springframework.session.web.http.CookieSerializer#readCookieValues(jakarta.
@@ -153,6 +155,9 @@ public void writeCookieValue(CookieValue cookieValue) {
153
155
if (this .sameSite != null ) {
154
156
sb .append ("; SameSite=" ).append (this .sameSite );
155
157
}
158
+ if (this .partitioned ) {
159
+ sb .append ("; Partitioned" );
160
+ }
156
161
response .addHeader ("Set-Cookie" , sb .toString ());
157
162
}
158
163
@@ -444,4 +449,12 @@ public String getRememberMeRequestAttribute() {
444
449
return this .rememberMeRequestAttribute ;
445
450
}
446
451
452
+ /**
453
+ * Allows defining whether the generated cookie carries the Partitioned attribute
454
+ * @since 3.4
455
+ */
456
+ public void setPartitioned (boolean partitioned ) {
457
+ this .partitioned = partitioned ;
458
+ }
459
+
447
460
}
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2014-2021 the original author or authors.
2
+ * Copyright 2014-2024 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -460,6 +460,13 @@ void writeCookieSetSameSiteNull() {
460
460
assertThat (getCookie ().getSameSite ()).isNull ();
461
461
}
462
462
463
+ @ Test
464
+ void writeCookieWhenPartitionedTrueThenSetPartitionedAttribute () {
465
+ this .serializer .setPartitioned (true );
466
+ this .serializer .writeCookieValue (cookieValue (this .sessionId ));
467
+ assertThat (getCookie ().isPartitioned ()).isTrue ();
468
+ }
469
+
463
470
void setCookieName (String cookieName ) {
464
471
this .cookieName = cookieName ;
465
472
this .serializer .setCookieName (cookieName );
Original file line number Diff line number Diff line change 1
- = What's New
1
+ = What's New in 3.4
2
2
3
- - xref:configuration/common.adoc#changing-how-session-ids-are-generated[docs] - https://github.com/spring-projects/spring-session/issues/11[gh-11] - Introduce `SessionIdGenerator` to allow custom session id generation
4
- - xref:configuration/redis.adoc#configuring-redis-session-mapper[docs] - https://github.com/spring-projects/spring-session/issues/2021[gh-2021] - Allow safe deserialization of Redis sessions
3
+ - https://github.com/spring-projects/spring-session/issues/2787[gh-2787] - Add Partitioned Cookie Support to `DefaultCookieSerializer`
You can’t perform that action at this time.
0 commit comments