mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-08 05:02:13 +00:00
Add Cookie Customizer Migration Steps
This commit is contained in:
parent
74a25c3fc1
commit
84db5bb312
@ -521,3 +521,49 @@ Xml::
|
||||
=====
|
||||
If you have several circumstances where HTTP is needed, consider using `OrRequestMatcher` to combine them into a single `RequestMatcher` instance.
|
||||
=====
|
||||
|
||||
== Use `setCookieCustomizer` instead of individual setters
|
||||
|
||||
In favor of a simpler API, `CookieCsrfTokenRepository#setCookieCustomizer` allows you to change any aspect of the cookie, replacing `setCookieHttpOnly`, `setCookieMaxAge`, `setSecure`, and `setCookieDomain`.
|
||||
|
||||
Change this:
|
||||
|
||||
[tabs]
|
||||
======
|
||||
Java::
|
||||
+
|
||||
[source,java,role="primary"]
|
||||
----
|
||||
CookeCsrfTokenRepository csrf = CookeCsrfTokenRepository.withHttpOnlyFalse();
|
||||
csrf.setCookieMaxAge(86400)
|
||||
----
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,role="secondary"]
|
||||
----
|
||||
val csrf = CookeCsrfTokenRepository.withHttpOnlyFalse()
|
||||
csrf.setCookieMaxAge(86400)
|
||||
----
|
||||
======
|
||||
|
||||
to this:
|
||||
|
||||
[tabs]
|
||||
======
|
||||
Java::
|
||||
+
|
||||
[source,java,role="primary"]
|
||||
----
|
||||
CookeCsrfTokenRepository csrf = CookeCsrfTokenRepository.withHttpOnlyFalse();
|
||||
csrf.setCookieCustomizer((c) -> c.maxAge(86400));
|
||||
----
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,role="secondary"]
|
||||
----
|
||||
val csrf = CookeCsrfTokenRepository.withHttpOnlyFalse()
|
||||
csrf.setCookieCustomizer { -> it.maxAge(86400) }
|
||||
----
|
||||
======
|
||||
|
Loading…
x
Reference in New Issue
Block a user