Testing with CSRF
Spring Security 还提供对 CSRF 测试的支持,例如 WebTestClient
:
-
Java
-
Kotlin
import static org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.csrf;
this.rest
// provide a valid CSRF token
.mutateWith(csrf())
.post()
.uri("/login")
...
import org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.csrf
this.rest
// provide a valid CSRF token
.mutateWith(csrf())
.post()
.uri("/login")
...