Skip to content

Since symfony/security-csrf 5.3: Using SessionTokenStorage without a session has no effect and is deprecated #46961

Answered by arderyp
arderyp asked this question in Q&A
Discussion options

You must be logged in to vote

I've figured it out. Right now, the solution requires replicating and enhancing the loginUser() function on KernelBrowser. I will submit a PR to symfony to make this achievable without needing to do so. Who knows if they will accept it. For now:

use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\BrowserKit\Cookie;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\User\UserInterface;

abstract class AbstractWebTestCase extends WebTestCase
{
    private KernelBrowser $client;
    private Ses…

Replies: 7 comments 15 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@nicodemuz
Comment options

@arderyp
Comment options

@stof
Comment options

@arderyp
Comment options

Comment options

You must be logged in to vote
1 reply
@arderyp
Comment options

Answer selected by arderyp
Comment options

You must be logged in to vote
10 replies
@dreis2211
Comment options

@arderyp
Comment options

@marien-probesys
Comment options

@dreis2211
Comment options

@dreis2211
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
7 participants
Converted from issue

This discussion was converted from issue #46955 on July 17, 2022 14:14.