Skip to content

SecurityMockMvcRequestPostProcessors.csrf() doesn't work with XorCsrfTokenRequestAttributeHandler #14125

Closed
@ch4mpy

Description

@ch4mpy

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.

Metadata

Metadata

Assignees

Labels

in: testAn issue in spring-security-testtype: bugA general bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions