Skip to content

Latest commit

 

History

History
34 lines (29 loc) · 639 Bytes

File metadata and controls

34 lines (29 loc) · 639 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")
    ...