Skip to content

Files

Latest commit

Jun 19, 2023
0cf95db · Jun 19, 2023

History

History
35 lines (30 loc) · 637 Bytes

File metadata and controls

35 lines (30 loc) · 637 Bytes

Testing with CSRF

Spring Security also provides support for CSRF testing with WebTestClient. For example:

Java
import static org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.csrf;

this.rest
	// provide a valid CSRF token
	.mutateWith(csrf())
	.post()
	.uri("/login")
	...
Kotlin
import org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.csrf

this.rest
    // provide a valid CSRF token
    .mutateWith(csrf())
    .post()
    .uri("/login")
    ...