summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Core/Authentication/Provider/RememberMeAuthenticationProvider.php2
-rw-r--r--Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php20
-rw-r--r--Http/Firewall/SimplePreAuthenticationListener.php6
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) {