Skip to content

Commit 26fbfc8

Browse files
committed
security #16631 n/a (xabbuh)
This PR was merged into the 2.3 branch. Discussion ---------- n/a n/a Commits ------- f88e600 migrate session after remember me authentication
2 parents 3fbdac1 + 79151d6 commit 26fbfc8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Firewall/RememberMeListener.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
2121
use Symfony\Component\Security\Http\SecurityEvents;
2222
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
23+
use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategy;
2324

2425
/**
2526
* RememberMeListener implements authentication capabilities via a cookie.
@@ -33,6 +34,7 @@ class RememberMeListener implements ListenerInterface
3334
private $authenticationManager;
3435
private $logger;
3536
private $dispatcher;
37+
private $sessionStrategy;
3638

3739
/**
3840
* Constructor.
@@ -50,6 +52,7 @@ public function __construct(SecurityContextInterface $securityContext, RememberM
5052
$this->authenticationManager = $authenticationManager;
5153
$this->logger = $logger;
5254
$this->dispatcher = $dispatcher;
55+
$this->sessionStrategy = new SessionAuthenticationStrategy(SessionAuthenticationStrategy::MIGRATE);
5356
}
5457

5558
/**
@@ -70,6 +73,11 @@ public function handle(GetResponseEvent $event)
7073

7174
try {
7275
$token = $this->authenticationManager->authenticate($token);
76+
77+
if ($request->hasSession() && $request->getSession()->isStarted()) {
78+
$this->sessionStrategy->onAuthentication($request, $token);
79+
}
80+
7381
$this->securityContext->setToken($token);
7482

7583
if (null !== $this->dispatcher) {

0 commit comments

Comments
 (0)