csrf.adoc 620 B

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