Skip to content

Commit 19f7b5f

Browse files
Merge branch '5.4' into 6.3
* 5.4: [TwigBridge] Add integration tests on twig code helpers [TwigBridge] Ensure CodeExtension's filters properly escape their input do not emit an error if an issue suppression handler was not used [Security] Fix possible session fixation when only the *token* changes [HttpClient] fix missing dep Update VERSION for 4.4.50 Update CHANGELOG for 4.4.50
2 parents 573ef96 + 6d3cd5a commit 19f7b5f

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

EventListener/SessionStrategyListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function onSuccessfulLogin(LoginSuccessEvent $event): void
4747
$user = $token->getUserIdentifier();
4848
$previousUser = $previousToken->getUserIdentifier();
4949

50-
if ('' !== ($user ?? '') && $user === $previousUser) {
50+
if ('' !== ($user ?? '') && $user === $previousUser && \get_class($token) === \get_class($previousToken)) {
5151
return;
5252
}
5353
}

Tests/EventListener/SessionStrategyListenerTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\HttpFoundation\Request;
1616
use Symfony\Component\HttpFoundation\Session\SessionInterface;
1717
use Symfony\Component\Security\Core\Authentication\Token\NullToken;
18+
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
1819
use Symfony\Component\Security\Core\User\InMemoryUser;
1920
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
2021
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
@@ -81,6 +82,26 @@ public function testRequestWithSamePreviousUser()
8182
$this->listener->onSuccessfulLogin($event);
8283
}
8384

85+
public function testRequestWithSamePreviousUserButDifferentTokenType()
86+
{
87+
$this->configurePreviousSession();
88+
89+
$token = $this->createMock(NullToken::class);
90+
$token->expects($this->once())
91+
->method('getUserIdentifier')
92+
->willReturn('test');
93+
$previousToken = $this->createMock(UsernamePasswordToken::class);
94+
$previousToken->expects($this->once())
95+
->method('getUserIdentifier')
96+
->willReturn('test');
97+
98+
$this->sessionAuthenticationStrategy->expects($this->once())->method('onAuthentication')->with($this->request, $token);
99+
100+
$event = new LoginSuccessEvent($this->createMock(AuthenticatorInterface::class), new SelfValidatingPassport(new UserBadge('test', function () {})), $token, $this->request, null, 'main_firewall', $previousToken);
101+
102+
$this->listener->onSuccessfulLogin($event);
103+
}
104+
84105
private function createEvent($firewallName)
85106
{
86107
return new LoginSuccessEvent($this->createMock(AuthenticatorInterface::class), new SelfValidatingPassport(new UserBadge('test', fn ($username) => new InMemoryUser($username, null))), $this->token, $this->request, null, $firewallName);

0 commit comments

Comments
 (0)