Skip to content

Commit 84db5bb

Browse files
committed
Add Cookie Customizer Migration Steps
1 parent 74a25c3 commit 84db5bb

File tree

1 file changed

+46
-0
lines changed
  • docs/modules/ROOT/pages/migration-7

1 file changed

+46
-0
lines changed

docs/modules/ROOT/pages/migration-7/web.adoc

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,3 +521,49 @@ Xml::
521521
=====
522522
If you have several circumstances where HTTP is needed, consider using `OrRequestMatcher` to combine them into a single `RequestMatcher` instance.
523523
=====
524+
525+
== Use `setCookieCustomizer` instead of individual setters
526+
527+
In favor of a simpler API, `CookieCsrfTokenRepository#setCookieCustomizer` allows you to change any aspect of the cookie, replacing `setCookieHttpOnly`, `setCookieMaxAge`, `setSecure`, and `setCookieDomain`.
528+
529+
Change this:
530+
531+
[tabs]
532+
======
533+
Java::
534+
+
535+
[source,java,role="primary"]
536+
----
537+
CookeCsrfTokenRepository csrf = CookeCsrfTokenRepository.withHttpOnlyFalse();
538+
csrf.setCookieMaxAge(86400)
539+
----
540+
541+
Kotlin::
542+
+
543+
[source,kotlin,role="secondary"]
544+
----
545+
val csrf = CookeCsrfTokenRepository.withHttpOnlyFalse()
546+
csrf.setCookieMaxAge(86400)
547+
----
548+
======
549+
550+
to this:
551+
552+
[tabs]
553+
======
554+
Java::
555+
+
556+
[source,java,role="primary"]
557+
----
558+
CookeCsrfTokenRepository csrf = CookeCsrfTokenRepository.withHttpOnlyFalse();
559+
csrf.setCookieCustomizer((c) -> c.maxAge(86400));
560+
----
561+
562+
Kotlin::
563+
+
564+
[source,kotlin,role="secondary"]
565+
----
566+
val csrf = CookeCsrfTokenRepository.withHttpOnlyFalse()
567+
csrf.setCookieCustomizer { -> it.maxAge(86400) }
568+
----
569+
======

0 commit comments

Comments
 (0)