diff options
author | Johannes Schmitt <schmittjoh@gmail.com> | 2011-01-25 20:28:26 +0100 |
---|---|---|
committer | Fabien Potencier <fabien.potencier@gmail.com> | 2011-01-26 16:38:54 +0100 |
commit | 521c9f65e9d70618f63ac6ed803a495651b9fd35 (patch) | |
tree | 4e64bf3f877a4050eb3eb95c0b55630a4105053c /Authentication/Token | |
parent | bff922f5c7ab61fb144e124b584da067842cb955 (diff) | |
download | symfony-security-521c9f65e9d70618f63ac6ed803a495651b9fd35.zip symfony-security-521c9f65e9d70618f63ac6ed803a495651b9fd35.tar.gz symfony-security-521c9f65e9d70618f63ac6ed803a495651b9fd35.tar.bz2 |
[Security] many improvements, and fixes
Diffstat (limited to 'Authentication/Token')
-rw-r--r-- | Authentication/Token/PreAuthenticatedToken.php | 10 | ||||
-rw-r--r-- | Authentication/Token/RememberMeToken.php | 28 | ||||
-rw-r--r-- | Authentication/Token/UsernamePasswordToken.php | 13 |
3 files changed, 40 insertions, 11 deletions
diff --git a/Authentication/Token/PreAuthenticatedToken.php b/Authentication/Token/PreAuthenticatedToken.php index 8c6fc5f..0980ae6 100644 --- a/Authentication/Token/PreAuthenticatedToken.php +++ b/Authentication/Token/PreAuthenticatedToken.php @@ -18,10 +18,12 @@ namespace Symfony\Component\Security\Authentication\Token; */ class PreAuthenticatedToken extends Token { + protected $providerKey; + /** * Constructor. */ - public function __construct($user, $credentials, array $roles = null) + public function __construct($user, $credentials, $providerKey, array $roles = null) { parent::__construct(null === $roles ? array() : $roles); if (null !== $roles) { @@ -30,6 +32,12 @@ class PreAuthenticatedToken extends Token $this->user = $user; $this->credentials = $credentials; + $this->providerKey = $providerKey; + } + + public function getProviderKey() + { + return $this->providerKey; } /** diff --git a/Authentication/Token/RememberMeToken.php b/Authentication/Token/RememberMeToken.php index 50284aa..f006a3a 100644 --- a/Authentication/Token/RememberMeToken.php +++ b/Authentication/Token/RememberMeToken.php @@ -22,6 +22,7 @@ use Symfony\Component\Security\User\AccountInterface; class RememberMeToken extends Token { protected $key; + protected $providerKey; /** * The persistent token which resulted in this authentication token. @@ -36,30 +37,39 @@ class RememberMeToken extends Token * @param string $username * @param string $key */ - public function __construct(AccountInterface $user, $key) { + public function __construct(AccountInterface $user, $providerKey, $key) { parent::__construct($user->getRoles()); - if (0 === strlen($key)) { - throw new \InvalidArgumentException('$key cannot be empty.'); + if (empty($key)) { + throw new \InvalidArgumentException('$key must not be empty.'); + } + if (empty($providerKey)) { + throw new \InvalidArgumentException('$providerKey must not be empty.'); } - $this->user = $user; + $this->setUser($user); + $this->providerKey = $providerKey; $this->key = $key; $this->setAuthenticated(true); } - public function getKey() + public function getProviderKey() { - return $this->key; + return $this->providerKey; } - public function setPersistentToken(PersistentTokenInterface $persistentToken) + public function getKey() { - $this->persistentToken = $persistentToken; + return $this->key; } public function getPersistentToken() { return $this->persistentToken; } -} + + public function setPersistentToken(PersistentTokenInterface $persistentToken) + { + $this->persistentToken = $persistentToken; + } +}
\ No newline at end of file diff --git a/Authentication/Token/UsernamePasswordToken.php b/Authentication/Token/UsernamePasswordToken.php index ed82ec8..1794481 100644 --- a/Authentication/Token/UsernamePasswordToken.php +++ b/Authentication/Token/UsernamePasswordToken.php @@ -18,19 +18,30 @@ namespace Symfony\Component\Security\Authentication\Token; */ class UsernamePasswordToken extends Token { + protected $providerKey; + /** * Constructor. + * + * @param string $user The username (like a nickname, email address, etc.) + * @param string $credentials This usually is the password of the user */ - public function __construct($user, $credentials, array $roles = array()) + public function __construct($user, $credentials, $providerKey, array $roles = array()) { parent::__construct($roles); $this->setUser($user); $this->credentials = $credentials; + $this->providerKey = $providerKey; parent::setAuthenticated((Boolean) count($roles)); } + public function getProviderKey() + { + return $this->providerKey; + } + /** * {@inheritdoc} */ |