mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-05-31 09:12:14 +00:00
Document reactive support for CSRF BREACH
Issue gh-11959
This commit is contained in:
parent
3cb2b0606e
commit
a61fffc209
@ -80,6 +80,45 @@ open fun securityWebFilterChain(http: HttpSecurity): SecurityWebFilterChain {
|
|||||||
----
|
----
|
||||||
====
|
====
|
||||||
|
|
||||||
|
=== Protect against CSRF BREACH
|
||||||
|
|
||||||
|
You can opt into Spring Security 6's default support for BREACH protection of the `CsrfToken` using the following configuration:
|
||||||
|
|
||||||
|
.`CsrfToken` BREACH Protection
|
||||||
|
====
|
||||||
|
.Java
|
||||||
|
[source,java,role="primary"]
|
||||||
|
----
|
||||||
|
@Bean
|
||||||
|
SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
|
||||||
|
XorServerCsrfTokenRequestAttributeHandler requestHandler = new XorServerCsrfTokenRequestAttributeHandler();
|
||||||
|
// ...
|
||||||
|
http
|
||||||
|
// ...
|
||||||
|
.csrf((csrf) -> csrf
|
||||||
|
.csrfTokenRequestHandler(requestHandler)
|
||||||
|
);
|
||||||
|
return http.build();
|
||||||
|
}
|
||||||
|
----
|
||||||
|
|
||||||
|
.Kotlin
|
||||||
|
[source,kotlin,role="secondary"]
|
||||||
|
----
|
||||||
|
@Bean
|
||||||
|
open fun securityWebFilterChain(http: HttpSecurity): SecurityWebFilterChain {
|
||||||
|
val requestHandler = XorServerCsrfTokenRequestAttributeHandler()
|
||||||
|
// ...
|
||||||
|
return http {
|
||||||
|
// ...
|
||||||
|
csrf {
|
||||||
|
csrfTokenRequestHandler = requestHandler
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
----
|
||||||
|
====
|
||||||
|
|
||||||
== Use `AuthorizationManager` for Method Security
|
== Use `AuthorizationManager` for Method Security
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user