Description
Describe the bug
Using SecurityMockMvcRequestPostProcessors.csrf()
gives invalid CSRF token when configuration contains csrf.csrfTokenRequestHandler(new XorCsrfTokenRequestAttributeHandler()::handle)
To Reproduce
Configure a servlet application with oauth2Login
and CSRF security for a SPA
Expected behavior
Test security framework should provide with the tooling to mimic a request from a SPA with valid CSRF token.
Sample
https://github.com/ch4mpy/reproducer_spring-security_gh-14125
This repo contains a minimal reproducer (reproducer-bff-servlet
module) with a failing test (ReproducerBffServletApplicationTests::givenCsrfTokenIsPresent_whenLogout_thenOk
).
It also contains an equivalent reactive app (which is not affected by the bug) and an Angular SPA working with both Spring backends.