You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
637 B
35 lines
637 B
= Testing with CSRF |
|
|
|
Spring Security also provides support for CSRF testing with `WebTestClient`. |
|
For example: |
|
|
|
[tabs] |
|
====== |
|
Java:: |
|
+ |
|
[source,java,role="primary"] |
|
---- |
|
import static org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.csrf; |
|
|
|
this.rest |
|
// provide a valid CSRF token |
|
.mutateWith(csrf()) |
|
.post() |
|
.uri("/login") |
|
... |
|
---- |
|
|
|
Kotlin:: |
|
+ |
|
[source,kotlin,role="secondary"] |
|
---- |
|
import org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.csrf |
|
|
|
this.rest |
|
// provide a valid CSRF token |
|
.mutateWith(csrf()) |
|
.post() |
|
.uri("/login") |
|
... |
|
---- |
|
======
|
|
|