使用 CSRF 進行測試
Spring Security 也提供使用 WebTestClient 進行 CSRF 測試的支援 — 例如
-
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")
...