Skip to content

Commit a7fbab5

Browse files
Merge branch '6.3' into 6.4
* 6.3: [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 [Webhook] Remove user-submitted type from HTTP response [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 073e568 + 19f7b5f commit a7fbab5

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

EventListener/SessionStrategyListener.php

+1-1
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

+21
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\HttpFoundation\Request;
1717
use Symfony\Component\HttpFoundation\Session\SessionInterface;
1818
use Symfony\Component\Security\Core\Authentication\Token\NullToken;
19+
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
1920
use Symfony\Component\Security\Core\User\InMemoryUser;
2021
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
2122
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
@@ -82,6 +83,26 @@ public function testRequestWithSamePreviousUser()
8283
$this->listener->onSuccessfulLogin($event);
8384
}
8485

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