10000 bug #13048 [Security] Delete old session on auth strategy migrate (xe… · symfony/symfony@901d1de · GitHub
[go: up one dir, main page]

Skip to content

Commit 901d1de

Browse files
committed
bug #13048 [Security] Delete old session on auth strategy migrate (xelaris)
This PR was merged into the 2.3 branch. Discussion ---------- [Security] Delete old session on auth strategy migrate | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #13026 | License | MIT | Doc PR | As identified by @austinh in #13026 there are two sessions after authentication, since the previous session is migrated to a new one by ``session_regenerate_id``. This PR ensures the old session is been deleted immediately on migration. I can't see any drawbacks, but if the change would break BC, another approach would be to add a new strategy like ``switch`` to enable instant deletion of the old session. Commits ------- 5dd11e6 [Security] Delete old session on auth strategy migrate
2 parents c5b9069 + 5dd11e6 commit 901d1de

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Symfony/Component/Security/Http/Session/SessionAuthenticationStrategy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function onAuthentication(Request $request, TokenInterface $token)
4747
return;
4848

4949
case self::MIGRATE:
50-
$request->getSession()->migrate();
50+
$request->getSession()->migrate(true);
5151

5252
return;
5353

src/Symfony/Component/Security/Tests/Http/Session/SessionAuthenticationStrategyTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testUnsupportedStrategy()
65B6 4747
public function testSessionIsMigrated()
4848
{
4949
$session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface');
50-
$session->expects($this->once())->method('migrate');
50+
$session->expects($this->once())->method('migrate')->with($this->equalTo(true));
5151

5252
$strategy = new SessionAuthenticationStrategy(SessionAuthenticationStrategy::MIGRATE);
5353
$strategy->onAuthentication($this->getRequest($session), $this->getToken());

0 commit comments

Comments
 (0)
0