summaryrefslogtreecommitdiffstats
path: root/Authentication/Provider/UserAuthenticationProvider.php
diff options
context:
space:
mode:
authorJohannes Schmitt <schmittjoh@gmail.com>2011-01-25 20:28:26 +0100
committerFabien Potencier <fabien.potencier@gmail.com>2011-01-26 16:38:54 +0100
commit521c9f65e9d70618f63ac6ed803a495651b9fd35 (patch)
tree4e64bf3f877a4050eb3eb95c0b55630a4105053c /Authentication/Provider/UserAuthenticationProvider.php
parentbff922f5c7ab61fb144e124b584da067842cb955 (diff)
downloadsymfony-security-521c9f65e9d70618f63ac6ed803a495651b9fd35.zip
symfony-security-521c9f65e9d70618f63ac6ed803a495651b9fd35.tar.gz
symfony-security-521c9f65e9d70618f63ac6ed803a495651b9fd35.tar.bz2
[Security] many improvements, and fixes
Diffstat (limited to 'Authentication/Provider/UserAuthenticationProvider.php')
-rw-r--r--Authentication/Provider/UserAuthenticationProvider.php12
1 files changed, 9 insertions, 3 deletions
diff --git a/Authentication/Provider/UserAuthenticationProvider.php b/Authentication/Provider/UserAuthenticationProvider.php
index 9ee4d61..fa678b7 100644
--- a/Authentication/Provider/UserAuthenticationProvider.php
+++ b/Authentication/Provider/UserAuthenticationProvider.php
@@ -29,6 +29,7 @@ abstract class UserAuthenticationProvider implements AuthenticationProviderInter
{
protected $hideUserNotFoundExceptions;
protected $accountChecker;
+ protected $providerKey;
/**
* Constructor.
@@ -36,9 +37,14 @@ abstract class UserAuthenticationProvider implements AuthenticationProviderInter
* @param AccountCheckerInterface $accountChecker An AccountCheckerInterface interface
* @param Boolean $hideUserNotFoundExceptions Whether to hide user not found exception or not
*/
- public function __construct(AccountCheckerInterface $accountChecker, $hideUserNotFoundExceptions = true)
+ public function __construct(AccountCheckerInterface $accountChecker, $providerKey, $hideUserNotFoundExceptions = true)
{
+ if (empty($providerKey)) {
+ throw new \InvalidArgumentException('$providerKey must not be empty.');
+ }
+
$this->accountChecker = $accountChecker;
+ $this->providerKey = $providerKey;
$this->hideUserNotFoundExceptions = $hideUserNotFoundExceptions;
}
@@ -64,7 +70,7 @@ abstract class UserAuthenticationProvider implements AuthenticationProviderInter
$this->checkAuthentication($user, $token);
$this->accountChecker->checkPostAuth($user);
- return new UsernamePasswordToken($user, $token->getCredentials(), $user->getRoles());
+ return new UsernamePasswordToken($user, $token->getCredentials(), $this->providerKey, $user->getRoles());
} catch (UsernameNotFoundException $notFound) {
if ($this->hideUserNotFoundExceptions) {
throw new BadCredentialsException('Bad credentials', 0, $notFound);
@@ -79,7 +85,7 @@ abstract class UserAuthenticationProvider implements AuthenticationProviderInter
*/
public function supports(TokenInterface $token)
{
- return $token instanceof UsernamePasswordToken;
+ return $token instanceof UsernamePasswordToken && $this->providerKey === $token->getProviderKey();
}
/**