2
0

csrf.adoc 622 B

12345678910111213141516171819202122232425262728293031
  1. = Testing with CSRF
  2. Spring Security also provides support for CSRF testing with `WebTestClient` -- for example:
  3. ====
  4. .Java
  5. [source,java,role="primary"]
  6. ----
  7. import static org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.csrf;
  8. this.rest
  9. // provide a valid CSRF token
  10. .mutateWith(csrf())
  11. .post()
  12. .uri("/login")
  13. ...
  14. ----
  15. .Kotlin
  16. [source,kotlin,role="secondary"]
  17. ----
  18. import org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.csrf
  19. this.rest
  20. // provide a valid CSRF token
  21. .mutateWith(csrf())
  22. .post()
  23. .uri("/login")
  24. ...
  25. ----
  26. ====