diff options
author | WouterJ <waldio.webdesign@gmail.com> | 2015-11-07 18:29:53 +0100 |
---|---|---|
committer | WouterJ <waldio.webdesign@gmail.com> | 2015-11-07 18:34:16 +0100 |
commit | b78eacaa57a9b0171fd4817b99510ab15f60d778 (patch) | |
tree | c6d7b18a19d39a5c808827e8a64b2c410523c292 | |
parent | 18ad89207b012a47457f4d0d7c6aaa57cb1f926c (diff) | |
download | symfony-security-b78eacaa57a9b0171fd4817b99510ab15f60d778.zip symfony-security-b78eacaa57a9b0171fd4817b99510ab15f60d778.tar.gz symfony-security-b78eacaa57a9b0171fd4817b99510ab15f60d778.tar.bz2 |
Renamed key to secretv2.8.0-BETA1
5 files changed, 30 insertions, 20 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 15d8d6f..84fe742 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,8 @@ CHANGELOG 2.8.0 ----- - * deprecated `getKey()` of the `AnonymousToken`, `RememberMeToken` and `AbstractRememberMeServices` classes - in favor of `getSecret()`. + * deprecated `getKey()` of the `AnonymousToken`, `RememberMeToken`, + `AbstractRememberMeServices` and `DigestAuthenticationEntryPoint` classes in favor of `getSecret()`. * deprecated `Symfony\Component\Security\Core\Authentication\SimplePreAuthenticatorInterface`, use `Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface` instead * deprecated `Symfony\Component\Security\Core\Authentication\SimpleFormAuthenticatorInterface`, use diff --git a/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php b/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php index 5b71747..8f4b392 100644 --- a/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php +++ b/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php @@ -33,7 +33,7 @@ class AnonymousAuthenticationProviderTest extends \PHPUnit_Framework_TestCase /** * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException */ - public function testAuthenticateWhenKeyIsNotValid() + public function testAuthenticateWhenSecretIsNotValid() { $provider = $this->getProvider('foo'); @@ -48,19 +48,19 @@ class AnonymousAuthenticationProviderTest extends \PHPUnit_Framework_TestCase $this->assertSame($token, $provider->authenticate($token)); } - protected function getSupportedToken($key) + protected function getSupportedToken($secret) { $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken', array('getSecret'), array(), '', false); $token->expects($this->any()) ->method('getSecret') - ->will($this->returnValue($key)) + ->will($this->returnValue($secret)) ; return $token; } - protected function getProvider($key) + protected function getProvider($secret) { - return new AnonymousAuthenticationProvider($key); + return new AnonymousAuthenticationProvider($secret); } } diff --git a/Http/EntryPoint/DigestAuthenticationEntryPoint.php b/Http/EntryPoint/DigestAuthenticationEntryPoint.php index 89f80ad..cdb98eb 100644 --- a/Http/EntryPoint/DigestAuthenticationEntryPoint.php +++ b/Http/EntryPoint/DigestAuthenticationEntryPoint.php @@ -24,15 +24,15 @@ use Psr\Log\LoggerInterface; */ class DigestAuthenticationEntryPoint implements AuthenticationEntryPointInterface { - private $key; + private $secret; private $realmName; private $nonceValiditySeconds; private $logger; - public function __construct($realmName, $key, $nonceValiditySeconds = 300, LoggerInterface $logger = null) + public function __construct($realmName, $secret, $nonceValiditySeconds = 300, LoggerInterface $logger = null) { $this->realmName = $realmName; - $this->key = $key; + $this->secret = $secret; $this->nonceValiditySeconds = $nonceValiditySeconds; $this->logger = $logger; } @@ -43,7 +43,7 @@ class DigestAuthenticationEntryPoint implements AuthenticationEntryPointInterfac public function start(Request $request, AuthenticationException $authException = null) { $expiryTime = microtime(true) + $this->nonceValiditySeconds * 1000; - $signatureValue = md5($expiryTime.':'.$this->key); + $signatureValue = md5($expiryTime.':'.$this->secret); $nonceValue = $expiryTime.':'.$signatureValue; $nonceValueBase64 = base64_encode($nonceValue); @@ -65,11 +65,21 @@ class DigestAuthenticationEntryPoint implements AuthenticationEntryPointInterfac } /** - * @return string + * @deprecated Since version 2.8, to be removed in 3.0. Use getSecret() instead. */ public function getKey() { - return $this->key; + @trigger_error(__method__.'() is deprecated since version 2.8 and will be removed in 3.0. Use getSecret() instead.', E_USER_DEPRECATED); + + return $this->getSecret(); + } + + /** + * @return string + */ + public function getSecret() + { + return $this->secret; } /** diff --git a/Http/Firewall/AnonymousAuthenticationListener.php b/Http/Firewall/AnonymousAuthenticationListener.php index f7feee8..0d60673 100644 --- a/Http/Firewall/AnonymousAuthenticationListener.php +++ b/Http/Firewall/AnonymousAuthenticationListener.php @@ -27,14 +27,14 @@ use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken; class AnonymousAuthenticationListener implements ListenerInterface { private $tokenStorage; - private $key; + private $secret; private $authenticationManager; private $logger; - public function __construct(TokenStorageInterface $tokenStorage, $key, LoggerInterface $logger = null, AuthenticationManagerInterface $authenticationManager = null) + public function __construct(TokenStorageInterface $tokenStorage, $secret, LoggerInterface $logger = null, AuthenticationManagerInterface $authenticationManager = null) { $this->tokenStorage = $tokenStorage; - $this->key = $key; + $this->secret = $secret; $this->authenticationManager = $authenticationManager; $this->logger = $logger; } @@ -51,7 +51,7 @@ class AnonymousAuthenticationListener implements ListenerInterface } try { - $token = new AnonymousToken($this->key, 'anon.', array()); + $token = new AnonymousToken($this->secret, 'anon.', array()); if (null !== $this->authenticationManager) { $token = $this->authenticationManager->authenticate($token); } diff --git a/Http/Tests/EntryPoint/DigestAuthenticationEntryPointTest.php b/Http/Tests/EntryPoint/DigestAuthenticationEntryPointTest.php index 181e340..4082986 100644 --- a/Http/Tests/EntryPoint/DigestAuthenticationEntryPointTest.php +++ b/Http/Tests/EntryPoint/DigestAuthenticationEntryPointTest.php @@ -23,7 +23,7 @@ class DigestAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase $authenticationException = new AuthenticationException('TheAuthenticationExceptionMessage'); - $entryPoint = new DigestAuthenticationEntryPoint('TheRealmName', 'TheKey'); + $entryPoint = new DigestAuthenticationEntryPoint('TheRealmName', 'TheSecret'); $response = $entryPoint->start($request, $authenticationException); $this->assertEquals(401, $response->getStatusCode()); @@ -34,7 +34,7 @@ class DigestAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase { $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); - $entryPoint = new DigestAuthenticationEntryPoint('TheRealmName', 'TheKey'); + $entryPoint = new DigestAuthenticationEntryPoint('TheRealmName', 'TheSecret'); $response = $entryPoint->start($request); $this->assertEquals(401, $response->getStatusCode()); @@ -47,7 +47,7 @@ class DigestAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase $nonceExpiredException = new NonceExpiredException('TheNonceExpiredExceptionMessage'); - $entryPoint = new DigestAuthenticationEntryPoint('TheRealmName', 'TheKey'); + $entryPoint = new DigestAuthenticationEntryPoint('TheRealmName', 'TheSecret'); $response = $entryPoint->start($request, $nonceExpiredException); $this->assertEquals(401, $response->getStatusCode()); |