Skip to content

Commit e1bd3ad

Browse files
committed
pass the current token to the checkPostAuth() method of user checkers
1 parent ee4f784 commit e1bd3ad

File tree

7 files changed

+16
-5
lines changed

7 files changed

+16
-5
lines changed

UPGRADE-7.2.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ If you're upgrading from a version below 7.1, follow the [7.1 upgrade guide](UPG
1111
Security
1212
--------
1313

14+
* Add `$token` argument to `UserCheckerInterface::checkPostAuth()`
1415
* Deprecate argument `$secret` of `RememberMeToken` and `RememberMeAuthenticator`
1516

1617
String

src/Symfony/Component/Security/Core/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
7.2
55
---
66

7+
* Add `$token` argument to `UserCheckerInterface::checkPostAuth()`
78
* Deprecate argument `$secret` of `RememberMeToken`
89

910
7.0

src/Symfony/Component/Security/Core/User/ChainUserChecker.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\Security\Core\User;
1313

14+
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
15+
1416
final class ChainUserChecker implements UserCheckerInterface
1517
{
1618
/**
@@ -27,10 +29,16 @@ public function checkPreAuth(UserInterface $user): void
2729
}
2830
}
2931

30-
public function checkPostAuth(UserInterface $user): void
32+
public function checkPostAuth(UserInterface $user /*, TokenInterface $token*/): void
3133
{
34+
$token = 1 < \func_num_args() ? func_get_arg(1) : 1;
35+
3236
foreach ($this->checkers as $checker) {
33-
$checker->checkPostAuth($user);
37+
if ($token instanceof TokenInterface) {
38+
$checker->checkPostAuth($user, $token);
39+
} else {
40+
$checker->checkPostAuth($user);
41+
}
3442
}
3543
}
3644
}

src/Symfony/Component/Security/Core/User/UserCheckerInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ public function checkPreAuth(UserInterface $user): void;
3535
*
3636
* @throws AccountStatusException
3737
*/
38-
public function checkPostAuth(UserInterface $user): void;
38+
public function checkPostAuth(UserInterface $user /*, TokenInterface $token*/): void;
3939
}

src/Symfony/Component/Security/Http/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
7.2
55
---
66

7+
* Pass the current token to the checkPostAuth() method of user checkers
78
* Deprecate argument `$secret` of `RememberMeAuthenticator`
89

910
7.1

src/Symfony/Component/Security/Http/EventListener/UserCheckerListener.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function postCheckCredentials(AuthenticationSuccessEvent $event): void
4747
return;
4848
}
4949

50-
$this->userChecker->checkPostAuth($user);
50+
$this->userChecker->checkPostAuth($user, $event->getAuthenticationToken());
5151
}
5252

5353
public static function getSubscribedEvents(): array

src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ private function attemptSwitchUser(Request $request, string $username): ?TokenIn
163163

164164
$this->logger?->info('Attempting to switch to user.', ['username' => $username]);
165165

166-
$this->userChecker->checkPostAuth($user);
166+
$this->userChecker->checkPostAuth($user, $token);
167167

168168
$roles = $user->getRoles();
169169
$originatedFromUri = str_replace('/&', '/?', preg_replace('#[&?]'.$this->usernameParameter.'=[^&]*#', '', $request->getRequestUri()));

0 commit comments

Comments
 (0)