[Routing][Security] When a #[Route]
is marked as stateless: true
and the SameOriginCsrfTokenManager.php
, the check fails
#59092
Labels
Symfony version(s) affected
7.2.0
Description
When a
#[Route]
is marked asstateless: true
and theSameOriginCsrfTokenManager.php
configuration is enabled, the stateless check fails because thehasSession(true)
condition passes and the code is executed when it shouldn't be. Therefore, the CSRF strategy is persisted in the session (I have acsrf-token
with the value1
instead of no value at all).To make the stateless check pass, I had to modify the following code:
to
@nicolas-grekas Maybe you wanted to check if the session was started instead of if a Session object exists ?
How to reproduce
Make a route marked as stateless. For instance:
And configure the app to use stateless CSRF token (https://symfony.com/blog/new-in-symfony-7-2-stateless-csrf)
Possible Solution
Check if the session is started instead of the session exists to define if a value must be written in the session or not.
Additional Context
No response
The text was updated successfully, but these errors were encountered: