Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.

Commit 3b19935

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 49553dc + b2e6411 commit 3b19935

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

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

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()
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)