New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[KernelBrowser] loginUser does not work with lazy session #49116
Comments
Confirming an issue here as well. After upgrading to 5.4.19, when@test:
security:
firewalls:
main:
http_basic: ~ Test: $user = //retrieve user object
$client = static::createClient();
$client->loginUser($user, 'main');
$client->get('/admin/');
$this->assertEquals(200, $client->getResponse()->getStatusCode()); Response:
|
Can you figure out the issue? Or maybe which PR introduced the regression among #49086 maybe? |
The With |
Thanks @micheh. Can you provide a small reproducing app? That'd help a lot the person that will work on the fix (could be you ;)) @mikeyudin looks like you're having another issue since this looks like a regression for you. Can you try figuring out either a reproducing app or at least the PR that introduced the issue? |
@nicolas-grekas -- Yes, I'm looking into it. It appears as though a transitive dependency is pulling in |
Symfony version(s) affected
5.4.19
Description
In functional tests, the
KernelBrowser::loginUser()
does not seem to support lazy sessions.For example,
Symfony\Bundle\FrameworkBundle\KernelBrowser::loginUser
creates a session withMOCKSESSID=d3d...
. The specified user is now in the token storage as expected.Symfony\Bundle\SecurityBundle\Security\LazyFirewallContext::__invoke
then sets the initializer of the token storage, which will callSymfony\Component\Security\Http\Firewall\ContextListener::authenticate
when needed.But then
ContextListener::authenticate()
will use a different session (e.g.MOCKSESSID=25f...
) than the one created by theKernelBrowser
. Therefore the context listener cannot fetch the token from the session and will overwrite the existing user set by theKernelBrowser
withnull
. The request inContextListener::authenticate()
has the correct cookie with the expected session id (MOCKSESSID=d3d...
), but somehow a different session id is used.The test works with
lazy: false
, but fails withlazy: true
.How to reproduce
Security configuration:
Test:
Controller:
Possible Solution
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: