You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/migration/servlet/exploits.adoc
+77
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,7 @@ In Spring Security 6, the default is that the lookup of the `CsrfToken` will be
11
11
12
12
To opt into the new Spring Security 6 default, the following configuration can be used.
13
13
14
+
[[servlet-opt-in-defer-loading-csrf-token]]
14
15
.Defer Loading `CsrfToken`
15
16
====
16
17
.Java
@@ -166,3 +167,79 @@ open fun springSecurity(http: HttpSecurity): SecurityFilterChain {
166
167
p:csrfRequestAttributeName="_csrf"/>
167
168
----
168
169
====
170
+
171
+
[[servlet-csrf-breach-opt-out]]
172
+
=== Opt-out Steps
173
+
174
+
If configuring CSRF BREACH protection gives you trouble, take a look at these scenarios for optimal opt out behavior:
175
+
176
+
==== I am using AngularJS or another Javascript framework
177
+
178
+
If you are using AngularJS and the https://angular.io/api/common/http/HttpClientXsrfModule[HttpClientXsrfModule] (or a similar module in another framework) along with `CookieCsrfTokenRepository.withHttpOnlyFalse()`, you may find that automatic support no longer works.
179
+
180
+
In this case, you can configure Spring Security to validate the raw `CsrfToken` from the cookie while keeping CSRF BREACH protection of the response using a custom `CsrfTokenRequestHandler` with delegation, like so:
181
+
182
+
.Configure `CsrfToken` BREACH Protection to validate raw tokens
183
+
====
184
+
.Java
185
+
[source,java,role="primary"]
186
+
----
187
+
@Bean
188
+
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
==== I need to opt out of CSRF BREACH protection for another reason
244
+
245
+
If CSRF BREACH protection does not work for you for another reason, you can opt out using the configuration from the <<servlet-opt-in-defer-loading-csrf-token>> section.
0 commit comments