Skip to content

Commit 84b956c

Browse files
author
Boris Vujicic
committed
[Security] added userChecker to SimpleAuthenticationProvider
Added UserChecker to SimpleAuthenticationProvider and updated SimpleFormFactory
1 parent 3ff74ad commit 84b956c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimpleFormFactory.php

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ protected function createAuthProvider(ContainerBuilder $container, $id, $config,
5555
->replaceArgument(0, new Reference($config['authenticator']))
5656
->replaceArgument(1, new Reference($userProviderId))
5757
->replaceArgument(2, $id)
58+
->replaceArgument(3, new Reference('security.user_checker.'.$id))
5859
;
5960

6061
return $provider;

src/Symfony/Component/Security/Core/Authentication/Provider/SimpleAuthenticationProvider.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Security\Core\Authentication\Provider;
1313

14+
use Symfony\Component\Security\Core\User\UserCheckerInterface;
1415
use Symfony\Component\Security\Core\User\UserProviderInterface;
1516
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1617
use Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface;
@@ -24,17 +25,22 @@ class SimpleAuthenticationProvider implements AuthenticationProviderInterface
2425
private $simpleAuthenticator;
2526
private $userProvider;
2627
private $providerKey;
28+
private $userChecker;
2729

28-
public function __construct(SimpleAuthenticatorInterface $simpleAuthenticator, UserProviderInterface $userProvider, $providerKey)
30+
public function __construct(SimpleAuthenticatorInterface $simpleAuthenticator, UserProviderInterface $userProvider, $providerKey, UserCheckerInterface $userChecker)
2931
{
3032
$this->simpleAuthenticator = $simpleAuthenticator;
3133
$this->userProvider = $userProvider;
3234
$this->providerKey = $providerKey;
35+
$this->userChecker = $userChecker;
3336
}
3437

3538
public function authenticate(TokenInterface $token)
3639
{
40+
$user = $this->userProvider->loadUserByUsername($token->getUsername());
41+
$this->userChecker->checkPreAuth($user);
3742
$authToken = $this->simpleAuthenticator->authenticateToken($token, $this->userProvider, $this->providerKey);
43+
$this->userChecker->checkPostAuth($user);
3844

3945
if ($authToken instanceof TokenInterface) {
4046
return $authToken;

0 commit comments

Comments
 (0)