summaryrefslogtreecommitdiffstats
path: root/Authentication
diff options
context:
space:
mode:
Diffstat (limited to 'Authentication')
-rw-r--r--Authentication/Provider/DaoAuthenticationProvider.php23
-rw-r--r--Authentication/Provider/UserAuthenticationProvider.php23
-rw-r--r--Authentication/Token/Token.php13
-rw-r--r--Authentication/Token/TokenInterface.php7
-rw-r--r--Authentication/Token/UsernamePasswordToken.php3
5 files changed, 22 insertions, 47 deletions
diff --git a/Authentication/Provider/DaoAuthenticationProvider.php b/Authentication/Provider/DaoAuthenticationProvider.php
index 34880b2..4f93440 100644
--- a/Authentication/Provider/DaoAuthenticationProvider.php
+++ b/Authentication/Provider/DaoAuthenticationProvider.php
@@ -78,28 +78,21 @@ class DaoAuthenticationProvider extends UserAuthenticationProvider
{
$user = $token->getUser();
if ($user instanceof AccountInterface) {
- return array($user, $token->getUserProviderName());
+ return $user;
}
- $result = null;
try {
- $result = $this->userProvider->loadUserByUsername($username);
+ $user = $this->userProvider->loadUserByUsername($username);
+
+ if (!$user instanceof AccountInterface) {
+ throw new AuthenticationServiceException('The user provider must return an AccountInterface object.');
+ }
+
+ return $user;
} catch (UsernameNotFoundException $notFound) {
throw $notFound;
} catch (\Exception $repositoryProblem) {
throw new AuthenticationServiceException($repositoryProblem->getMessage(), $token, 0, $repositoryProblem);
}
-
- if (!is_array($result) || 2 !== count($result)) {
- throw new AuthenticationServiceException('User provider did not return an array, or array had invalid format.');
- }
- if (!$result[0] instanceof AccountInterface) {
- throw new AuthenticationServiceException('The user provider must return an AccountInterface object.');
- }
- if (empty($result[1])) {
- throw new AuthenticationServiceException('The user provider must return a non-empty user provider name.');
- }
-
- return $result;
}
}
diff --git a/Authentication/Provider/UserAuthenticationProvider.php b/Authentication/Provider/UserAuthenticationProvider.php
index f621e42..b5e2dbb 100644
--- a/Authentication/Provider/UserAuthenticationProvider.php
+++ b/Authentication/Provider/UserAuthenticationProvider.php
@@ -54,7 +54,17 @@ abstract class UserAuthenticationProvider implements AuthenticationProviderInter
$username = null === $token->getUser() ? 'NONE_PROVIDED' : (string) $token;
try {
- $result = $this->retrieveUser($username, $token);
+ $user = $this->retrieveUser($username, $token);
+
+ if (!$user instanceof AccountInterface) {
+ throw new AuthenticationServiceException('retrieveUser() must return an AccountInterface.');
+ }
+
+ $this->accountChecker->checkPreAuth($user);
+ $this->checkAuthentication($user, $token);
+ $this->accountChecker->checkPostAuth($user);
+
+ return new UsernamePasswordToken($user, $token->getCredentials(), $user->getRoles());
} catch (UsernameNotFoundException $notFound) {
if ($this->hideUserNotFoundExceptions) {
throw new BadCredentialsException('Bad credentials', 0, $notFound);
@@ -62,17 +72,6 @@ abstract class UserAuthenticationProvider implements AuthenticationProviderInter
throw $notFound;
}
-
- if (!is_array($result) || 2 !== count($result)) {
- throw new AuthenticationServiceException('retrieveUser() did not return an array, or array had invalid format.');
- }
- list($user, $userProviderName) = $result;
-
- $this->accountChecker->checkPreAuth($user);
- $this->checkAuthentication($user, $token);
- $this->accountChecker->checkPostAuth($user);
-
- return new UsernamePasswordToken($user, $token->getCredentials(), $userProviderName, $user->getRoles());
}
/**
diff --git a/Authentication/Token/Token.php b/Authentication/Token/Token.php
index 37b7ded..8927c80 100644
--- a/Authentication/Token/Token.php
+++ b/Authentication/Token/Token.php
@@ -26,7 +26,6 @@ abstract class Token implements TokenInterface
protected $roles;
protected $authenticated;
protected $user;
- protected $userProviderName;
protected $credentials;
protected $immutable;
@@ -167,14 +166,6 @@ abstract class Token implements TokenInterface
}
/**
- * {@inheritDoc}
- */
- public function getUserProviderName()
- {
- return $this->userProviderName;
- }
-
- /**
* {@inheritdoc}
*/
public function isImmutable()
@@ -195,7 +186,7 @@ abstract class Token implements TokenInterface
*/
public function serialize()
{
- return serialize(array($this->user, $this->userProviderName, $this->credentials, $this->authenticated, $this->roles, $this->immutable));
+ return serialize(array($this->user, $this->credentials, $this->authenticated, $this->roles, $this->immutable));
}
/**
@@ -203,6 +194,6 @@ abstract class Token implements TokenInterface
*/
public function unserialize($serialized)
{
- list($this->user, $this->userProviderName, $this->credentials, $this->authenticated, $this->roles, $this->immutable) = unserialize($serialized);
+ list($this->user, $this->credentials, $this->authenticated, $this->roles, $this->immutable) = unserialize($serialized);
}
}
diff --git a/Authentication/Token/TokenInterface.php b/Authentication/Token/TokenInterface.php
index 4f37522..2b50693 100644
--- a/Authentication/Token/TokenInterface.php
+++ b/Authentication/Token/TokenInterface.php
@@ -66,13 +66,6 @@ interface TokenInterface extends \Serializable
function setUser($user);
/**
- * Returns a unique id for the user provider that was used to retrieve the user
- *
- * @return string
- */
- function getUserProviderName();
-
- /**
* Checks if the user is authenticated or not.
*
* @return Boolean true if the token has been authenticated, false otherwise
diff --git a/Authentication/Token/UsernamePasswordToken.php b/Authentication/Token/UsernamePasswordToken.php
index ce11cb3..021a90e 100644
--- a/Authentication/Token/UsernamePasswordToken.php
+++ b/Authentication/Token/UsernamePasswordToken.php
@@ -21,13 +21,12 @@ class UsernamePasswordToken extends Token
/**
* Constructor.
*/
- public function __construct($user, $credentials, $userProviderName = null, array $roles = array())
+ public function __construct($user, $credentials, array $roles = array())
{
parent::__construct($roles);
$this->setUser($user);
$this->credentials = $credentials;
- $this->userProviderName = $userProviderName;
parent::setAuthenticated((Boolean) count($roles));
}