Skip to content

Commit 6641b8c

Browse files
author
Steve Riesenberg
committed
Document deprecation of tokenFromMultipartDataEnabled
Issue spring-projectsgh-12020
1 parent 17123a3 commit 6641b8c

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

docs/modules/ROOT/pages/migration/reactive.adoc

+78
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,84 @@
22

33
If you have already performed the xref:migration/index.adoc[initial migration steps] for your Reactive application, you're now ready to perform steps specific to Reactive applications.
44

5+
== Exploit Protection Migrations
6+
7+
The following steps relate to changes around how to configure CSRF.
8+
9+
=== Configure `tokenFromMultipartDataEnabled`
10+
11+
In Spring Security 5.8, the method `tokenFromMultipartDataEnabled` was deprecated in favor of `ServerCsrfTokenRequestAttributeHandler#setTokenFromMultipartDataEnabled`.
12+
13+
To address the deprecation, the following code:
14+
15+
.Configure `tokenFromMultipartDataEnabled` with DSL
16+
====
17+
.Java
18+
[source,java,role="primary"]
19+
----
20+
@Bean
21+
SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
22+
http
23+
// ...
24+
.csrf((csrf) -> csrf
25+
.tokenFromMultipartDataEnabled(true)
26+
);
27+
return http.build();
28+
}
29+
----
30+
31+
.Kotlin
32+
[source,kotlin,role="secondary"]
33+
----
34+
@Bean
35+
open fun securityWebFilterChain(http: HttpSecurity): SecurityWebFilterChain {
36+
return http {
37+
// ...
38+
csrf {
39+
tokenFromMultipartDataEnabled = true
40+
}
41+
}
42+
}
43+
----
44+
====
45+
46+
can be replaced with:
47+
48+
.Configure `tokenFromMultipartDataEnabled` with `ServerCsrfTokenRequestAttributeHandler`
49+
====
50+
.Java
51+
[source,java,role="primary"]
52+
----
53+
@Bean
54+
SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
55+
ServerCsrfTokenRequestAttributeHandler requestHandler = new ServerCsrfTokenRequestAttributeHandler();
56+
requestHandler.setTokenFromMultipartDataEnabled(true);
57+
http
58+
// ...
59+
.csrf((csrf) -> csrf
60+
.csrfTokenRequestHandler(requestHandler)
61+
);
62+
return http.build();
63+
}
64+
----
65+
66+
.Kotlin
67+
[source,kotlin,role="secondary"]
68+
----
69+
@Bean
70+
open fun securityWebFilterChain(http: HttpSecurity): SecurityWebFilterChain {
71+
val requestHandler = ServerCsrfTokenRequestAttributeHandler()
72+
requestHandler.tokenFromMultipartDataEnabled = true
73+
return http {
74+
// ...
75+
csrf {
76+
csrfTokenRequestHandler = requestHandler
77+
}
78+
}
79+
}
80+
----
81+
====
82+
583
== Use `AuthorizationManager` for Method Security
684

785
xref:reactive/authorization/method.adoc[Method Security] has been xref:reactive/authorization/method.adoc#jc-enable-reactive-method-security-authorization-manager[improved] through {security-api-url}org/springframework/security/authorization/AuthorizationManager.html[the `AuthorizationManager` API] and direct use of Spring AOP.

0 commit comments

Comments
 (0)