diff options
author | Bernhard Schussek <bschussek@gmail.com> | 2014-09-25 11:52:29 +0200 |
---|---|---|
committer | Bernhard Schussek <bschussek@gmail.com> | 2014-09-25 11:52:29 +0200 |
commit | 5aa642a5ad4022f377c0eb43115d754dc92c4ae0 (patch) | |
tree | 9f291e6f94c5244679d2aa7cb00c3b37f3223b46 | |
parent | 133d64ad84f9e37d681c70db8a05743fa2001e11 (diff) | |
parent | 659aaeaa6f12334c2946acaeca5f530f8caa74bb (diff) | |
download | symfony-security-5aa642a5ad4022f377c0eb43115d754dc92c4ae0.zip symfony-security-5aa642a5ad4022f377c0eb43115d754dc92c4ae0.tar.gz symfony-security-5aa642a5ad4022f377c0eb43115d754dc92c4ae0.tar.bz2 |
Merge branch '2.4' into 2.5
* 2.4:
[Form] Removed constructor argument from FormTypeHttpFoundationExtension for forward compatibility with 2.5
[Validator] Simplified testing of violations
remove obsolete test file
[FrameworkBundle] output failed matched path for clarification
bug #10242 Missing checkPreAuth from RememberMeAuthenticationProvider
[Validator] Fixed StaticMethodLoaderTest to actually test something
[Form] Fixed ValidatorTypeGuesser to guess properties without constraints not to be required
Use request format from request in twig ExceptionController
fixed bug
added the possibility to return null from SimplePreAuthenticationListener
[Form] Moved POST_MAX_SIZE validation from FormValidator to request handler
[Form] Add a form error if post_max_size has been reached.
Response::isNotModified returns true when If-Modified-Since is later than Last-Modified
[WebProfilerBundle] turbolinks compatibility
Conflicts:
src/Symfony/Component/Form/Extension/Core/Type/FormType.php
src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php
src/Symfony/Component/Form/Extension/Validator/Util/ServerParams.php
src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php
src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php
3 files changed, 15 insertions, 13 deletions
diff --git a/Core/Authentication/Provider/RememberMeAuthenticationProvider.php b/Core/Authentication/Provider/RememberMeAuthenticationProvider.php index 234bddb..82be1d1 100644 --- a/Core/Authentication/Provider/RememberMeAuthenticationProvider.php +++ b/Core/Authentication/Provider/RememberMeAuthenticationProvider.php @@ -50,7 +50,7 @@ class RememberMeAuthenticationProvider implements AuthenticationProviderInterfac } $user = $token->getUser(); - $this->userChecker->checkPostAuth($user); + $this->userChecker->checkPreAuth($user); $authenticatedToken = new RememberMeToken($user, $this->providerKey, $this->key); $authenticatedToken->setAttributes($token->getAttributes()); diff --git a/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php b/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php index d278ba4..a6fff4b 100644 --- a/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php +++ b/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php @@ -12,7 +12,7 @@ namespace Symfony\Component\Security\Core\Tests\Authentication\Provider; use Symfony\Component\Security\Core\Authentication\Provider\RememberMeAuthenticationProvider; -use Symfony\Component\Security\Core\Exception\AccountExpiredException; +use Symfony\Component\Security\Core\Exception\DisabledException; use Symfony\Component\Security\Core\Role\Role; class RememberMeAuthenticationProviderTest extends \PHPUnit_Framework_TestCase @@ -45,15 +45,14 @@ class RememberMeAuthenticationProviderTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Symfony\Component\Security\Core\Exception\AccountExpiredException + * @expectedException \Symfony\Component\Security\Core\Exception\DisabledException */ - public function testAuthenticateWhenPostChecksFails() + public function testAuthenticateWhenPreChecksFails() { $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface'); $userChecker->expects($this->once()) - ->method('checkPostAuth') - ->will($this->throwException(new AccountExpiredException())) - ; + ->method('checkPreAuth') + ->will($this->throwException(new DisabledException())); $provider = $this->getProvider($userChecker); @@ -65,8 +64,7 @@ class RememberMeAuthenticationProviderTest extends \PHPUnit_Framework_TestCase $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); $user->expects($this->exactly(2)) ->method('getRoles') - ->will($this->returnValue(array('ROLE_FOO'))) - ; + ->will($this->returnValue(array('ROLE_FOO'))); $provider = $this->getProvider(); @@ -86,16 +84,14 @@ class RememberMeAuthenticationProviderTest extends \PHPUnit_Framework_TestCase $user ->expects($this->any()) ->method('getRoles') - ->will($this->returnValue(array())) - ; + ->will($this->returnValue(array())); } $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken', array('getProviderKey'), array($user, 'foo', $key)); $token ->expects($this->once()) ->method('getProviderKey') - ->will($this->returnValue('foo')) - ; + ->will($this->returnValue('foo')); return $token; } diff --git a/Http/Firewall/SimplePreAuthenticationListener.php b/Http/Firewall/SimplePreAuthenticationListener.php index 258ca96..a6f4f77 100644 --- a/Http/Firewall/SimplePreAuthenticationListener.php +++ b/Http/Firewall/SimplePreAuthenticationListener.php @@ -76,6 +76,12 @@ class SimplePreAuthenticationListener implements ListenerInterface try { $token = $this->simpleAuthenticator->createToken($request, $this->providerKey); + + // allow null to be returned to skip authentication + if (null === $token) { + return; + } + $token = $this->authenticationManager->authenticate($token); $this->securityContext->setToken($token); } catch (AuthenticationException $e) { |