moved the secure random dep for remember me as a constructor argument

This commit is contained in:
Fabien Potencier 2012-10-27 10:25:20 +02:00
parent 248703f6d8
commit 5849855eb9
3 changed files with 20 additions and 6 deletions

View File

@ -45,7 +45,12 @@
class="%security.authentication.rememberme.services.persistent.class%"
parent="security.authentication.rememberme.services.abstract"
abstract="true">
<call method="setSecureRandom"><argument type="service" id="security.secure_random" /></call>
<argument type="collection" /> <!-- User Providers -->
<argument /> <!-- Shared Token Key -->
<argument /> <!-- Shared Provider Key -->
<argument type="collection" /> <!-- Options -->
<argument type="service" id="logger" on-invalid="null" />
<argument type="service" id="security.secure_random" />
</service>
<service id="security.authentication.rememberme.services.simplehash"

View File

@ -33,8 +33,20 @@ class PersistentTokenBasedRememberMeServices extends AbstractRememberMeServices
private $tokenProvider;
private $secureRandom;
public function setSecureRandom(SecureRandom $secureRandom)
/**
* Constructor
*
* @param array $userProviders
* @param string $key
* @param string $providerKey
* @param SecureRandom $secureRandom
* @param array $options
* @param LoggerInterface $logger
*/
public function __construct(array $userProviders, $key, $providerKey, array $options = array(), LoggerInterface $logger = null, SecureRandom $secureRandom)
{
parent::__construct($userProviders, $key, $providerKey, $options, $logger);
$this->secureRandom = $secureRandom;
}

View File

@ -319,10 +319,7 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test
$userProvider = $this->getProvider();
}
$r = new PersistentTokenBasedRememberMeServices(array($userProvider), 'fookey', 'fookey', $options, $logger);
$r->setSecureRandom(new SecureRandom());
return $r;
return new PersistentTokenBasedRememberMeServices(array($userProvider), 'fookey', 'fookey', $options, $logger, new SecureRandom());
}
protected function getProvider()