summaryrefslogtreecommitdiffstats
path: root/Http
diff options
context:
space:
mode:
Diffstat (limited to 'Http')
-rw-r--r--Http/AccessMap.php2
-rw-r--r--Http/Authentication/AuthenticationUtils.php86
-rw-r--r--Http/Authentication/DefaultAuthenticationFailureHandler.php6
-rw-r--r--Http/Authentication/DefaultAuthenticationSuccessHandler.php2
-rw-r--r--Http/Authentication/SimpleAuthenticationHandler.php4
-rw-r--r--Http/EntryPoint/FormAuthenticationEntryPoint.php4
-rw-r--r--Http/Firewall.php2
-rw-r--r--Http/Firewall/AbstractAuthenticationListener.php10
-rw-r--r--Http/Firewall/ContextListener.php4
-rw-r--r--Http/Firewall/LogoutListener.php2
-rw-r--r--Http/Firewall/RememberMeListener.php9
-rw-r--r--Http/Firewall/SimpleFormAuthenticationListener.php7
-rw-r--r--Http/Firewall/X509AuthenticationListener.php13
-rw-r--r--Http/FirewallMap.php2
-rw-r--r--Http/HttpUtils.php4
-rw-r--r--Http/Logout/DefaultLogoutSuccessHandler.php2
-rw-r--r--Http/README.md2
-rw-r--r--Http/RememberMe/AbstractRememberMeServices.php6
-rw-r--r--Http/RememberMe/PersistentTokenBasedRememberMeServices.php6
-rw-r--r--Http/RememberMe/ResponseListener.php2
-rw-r--r--Http/RememberMe/TokenBasedRememberMeServices.php10
-rw-r--r--Http/Session/SessionAuthenticationStrategy.php2
-rw-r--r--Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php2
-rw-r--r--Http/Tests/EntryPoint/RetryAuthenticationEntryPointTest.php10
-rw-r--r--Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php10
-rw-r--r--Http/Tests/Firewall/BasicAuthenticationListenerTest.php6
-rw-r--r--Http/Tests/Firewall/ContextListenerTest.php2
-rw-r--r--Http/Tests/Firewall/DigestDataTest.php50
-rw-r--r--Http/Tests/Firewall/RememberMeListenerTest.php111
-rw-r--r--Http/Tests/Firewall/SwitchUserListenerTest.php2
-rw-r--r--Http/Tests/Firewall/X509AuthenticationListenerTest.php53
-rw-r--r--Http/Tests/FirewallTest.php2
-rw-r--r--Http/Tests/HttpUtilsTest.php2
-rw-r--r--Http/Tests/RememberMe/AbstractRememberMeServicesTest.php2
-rw-r--r--Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php3
-rw-r--r--Http/Tests/RememberMe/ResponseListenerTest.php2
-rw-r--r--Http/composer.json2
37 files changed, 330 insertions, 116 deletions
diff --git a/Http/AccessMap.php b/Http/AccessMap.php
index dc2e66a..116874a 100644
--- a/Http/AccessMap.php
+++ b/Http/AccessMap.php
@@ -37,7 +37,7 @@ class AccessMap implements AccessMapInterface
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function getPatterns(Request $request)
{
diff --git a/Http/Authentication/AuthenticationUtils.php b/Http/Authentication/AuthenticationUtils.php
new file mode 100644
index 0000000..03f5e44
--- /dev/null
+++ b/Http/Authentication/AuthenticationUtils.php
@@ -0,0 +1,86 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Security\Http\Authentication;
+
+use Symfony\Component\HttpFoundation\RequestStack;
+use Symfony\Component\Security\Core\Exception\AuthenticationException;
+use Symfony\Component\Security\Core\SecurityContextInterface;
+use Symfony\Component\HttpFoundation\Request;
+
+/**
+ * Extracts Security Errors from Request
+ *
+ * @author Boris Vujicic <boris.vujicic@gmail.com>
+ */
+class AuthenticationUtils
+{
+ /**
+ * @var RequestStack
+ */
+ private $requestStack;
+
+ /**
+ * @param RequestStack $requestStack
+ */
+ public function __construct(RequestStack $requestStack)
+ {
+ $this->requestStack = $requestStack;
+ }
+
+ /**
+ * @param bool $clearSession
+ * @return null|AuthenticationException
+ */
+ public function getLastAuthenticationError($clearSession = true)
+ {
+ $request = $this->getRequest();
+ $session = $request->getSession();
+ $authenticationException = null;
+
+ if ($request->attributes->has(SecurityContextInterface::AUTHENTICATION_ERROR)) {
+ $authenticationException = $request->attributes->get(SecurityContextInterface::AUTHENTICATION_ERROR);
+ } elseif ($session !== null && $session->has(SecurityContextInterface::AUTHENTICATION_ERROR)) {
+ $authenticationException = $session->get(SecurityContextInterface::AUTHENTICATION_ERROR);
+
+ if ($clearSession) {
+ $session->remove(SecurityContextInterface::AUTHENTICATION_ERROR);
+ }
+ }
+
+ return $authenticationException;
+ }
+
+ /**
+ * @return string
+ */
+ public function getLastUsername()
+ {
+ $session = $this->getRequest()->getSession();
+
+ return null === $session ? '' : $session->get(SecurityContextInterface::LAST_USERNAME);
+ }
+
+ /**
+ * @return Request
+ * @throws \LogicException
+ */
+ private function getRequest()
+ {
+ $request = $this->requestStack->getCurrentRequest();
+
+ if (null === $request) {
+ throw new \LogicException('Request should exist so it can be processed for error.');
+ }
+
+ return $request;
+ }
+}
diff --git a/Http/Authentication/DefaultAuthenticationFailureHandler.php b/Http/Authentication/DefaultAuthenticationFailureHandler.php
index 70dcd1e..db96e67 100644
--- a/Http/Authentication/DefaultAuthenticationFailureHandler.php
+++ b/Http/Authentication/DefaultAuthenticationFailureHandler.php
@@ -53,17 +53,17 @@ class DefaultAuthenticationFailureHandler implements AuthenticationFailureHandle
'failure_path' => null,
'failure_forward' => false,
'login_path' => '/login',
- 'failure_path_parameter' => '_failure_path'
+ 'failure_path_parameter' => '_failure_path',
), $options);
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
{
if ($failureUrl = $request->get($this->options['failure_path_parameter'], null, true)) {
- $this->options['failure_path'] = $failureUrl;
+ $this->options['failure_path'] = $failureUrl;
}
if (null === $this->options['failure_path']) {
diff --git a/Http/Authentication/DefaultAuthenticationSuccessHandler.php b/Http/Authentication/DefaultAuthenticationSuccessHandler.php
index 0c084b9..54d6fc1 100644
--- a/Http/Authentication/DefaultAuthenticationSuccessHandler.php
+++ b/Http/Authentication/DefaultAuthenticationSuccessHandler.php
@@ -48,7 +48,7 @@ class DefaultAuthenticationSuccessHandler implements AuthenticationSuccessHandle
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function onAuthenticationSuccess(Request $request, TokenInterface $token)
{
diff --git a/Http/Authentication/SimpleAuthenticationHandler.php b/Http/Authentication/SimpleAuthenticationHandler.php
index 2280d8f..09a55ef 100644
--- a/Http/Authentication/SimpleAuthenticationHandler.php
+++ b/Http/Authentication/SimpleAuthenticationHandler.php
@@ -51,7 +51,7 @@ class SimpleAuthenticationHandler implements AuthenticationFailureHandlerInterfa
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function onAuthenticationSuccess(Request $request, TokenInterface $token)
{
@@ -78,7 +78,7 @@ class SimpleAuthenticationHandler implements AuthenticationFailureHandlerInterfa
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
{
diff --git a/Http/EntryPoint/FormAuthenticationEntryPoint.php b/Http/EntryPoint/FormAuthenticationEntryPoint.php
index b78f0a9..c734db0 100644
--- a/Http/EntryPoint/FormAuthenticationEntryPoint.php
+++ b/Http/EntryPoint/FormAuthenticationEntryPoint.php
@@ -34,14 +34,14 @@ class FormAuthenticationEntryPoint implements AuthenticationEntryPointInterface
* @param HttpKernelInterface $kernel
* @param HttpUtils $httpUtils An HttpUtils instance
* @param string $loginPath The path to the login form
- * @param Boolean $useForward Whether to forward or redirect to the login form
+ * @param bool $useForward Whether to forward or redirect to the login form
*/
public function __construct(HttpKernelInterface $kernel, HttpUtils $httpUtils, $loginPath, $useForward = false)
{
$this->httpKernel = $kernel;
$this->httpUtils = $httpUtils;
$this->loginPath = $loginPath;
- $this->useForward = (Boolean) $useForward;
+ $this->useForward = (bool) $useForward;
}
/**
diff --git a/Http/Firewall.php b/Http/Firewall.php
index 392da0b..7bad47a 100644
--- a/Http/Firewall.php
+++ b/Http/Firewall.php
@@ -85,7 +85,7 @@ class Firewall implements EventSubscriberInterface
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public static function getSubscribedEvents()
{
diff --git a/Http/Firewall/AbstractAuthenticationListener.php b/Http/Firewall/AbstractAuthenticationListener.php
index 7fa991c..cc1c4a1 100644
--- a/Http/Firewall/AbstractAuthenticationListener.php
+++ b/Http/Firewall/AbstractAuthenticationListener.php
@@ -149,14 +149,14 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
if ($returnValue instanceof TokenInterface) {
$this->sessionStrategy->onAuthentication($request, $returnValue);
- $response = $this->onSuccess($event, $request, $returnValue);
+ $response = $this->onSuccess($request, $returnValue);
} elseif ($returnValue instanceof Response) {
$response = $returnValue;
} else {
throw new \RuntimeException('attemptAuthentication() must either return a Response, an implementation of TokenInterface, or null.');
}
} catch (AuthenticationException $e) {
- $response = $this->onFailure($event, $request, $e);
+ $response = $this->onFailure($request, $e);
}
$event->setResponse($response);
@@ -171,7 +171,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
*
* @param Request $request
*
- * @return Boolean
+ * @return bool
*/
protected function requiresAuthentication(Request $request)
{
@@ -189,7 +189,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
*/
abstract protected function attemptAuthentication(Request $request);
- private function onFailure(GetResponseEvent $event, Request $request, AuthenticationException $failed)
+ private function onFailure(Request $request, AuthenticationException $failed)
{
if (null !== $this->logger) {
$this->logger->info(sprintf('Authentication request failed: %s', $failed->getMessage()));
@@ -209,7 +209,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
return $response;
}
- private function onSuccess(GetResponseEvent $event, Request $request, TokenInterface $token)
+ private function onSuccess(Request $request, TokenInterface $token)
{
if (null !== $this->logger) {
$this->logger->info(sprintf('User "%s" has been authenticated successfully', $token->getUsername()));
diff --git a/Http/Firewall/ContextListener.php b/Http/Firewall/ContextListener.php
index 05e260e..e61907e 100644
--- a/Http/Firewall/ContextListener.php
+++ b/Http/Firewall/ContextListener.php
@@ -142,7 +142,7 @@ class ContextListener implements ListenerInterface
*
* @throws \RuntimeException
*/
- private function refreshUser(TokenInterface $token)
+ protected function refreshUser(TokenInterface $token)
{
$user = $token->getUser();
if (!$user instanceof UserInterface) {
@@ -170,7 +170,7 @@ class ContextListener implements ListenerInterface
$this->logger->warning(sprintf('Username "%s" could not be found.', $notFound->getUsername()));
}
- return null;
+ return;
}
}
diff --git a/Http/Firewall/LogoutListener.php b/Http/Firewall/LogoutListener.php
index ed7f7fe..91f17bb 100644
--- a/Http/Firewall/LogoutListener.php
+++ b/Http/Firewall/LogoutListener.php
@@ -131,7 +131,7 @@ class LogoutListener implements ListenerInterface
*
* @param Request $request
*
- * @return Boolean
+ * @return bool
*/
protected function requiresLogout(Request $request)
{
diff --git a/Http/Firewall/RememberMeListener.php b/Http/Firewall/RememberMeListener.php
index 6ca3842..44000d3 100644
--- a/Http/Firewall/RememberMeListener.php
+++ b/Http/Firewall/RememberMeListener.php
@@ -33,6 +33,7 @@ class RememberMeListener implements ListenerInterface
private $authenticationManager;
private $logger;
private $dispatcher;
+ private $catchExceptions = true;
/**
* Constructor.
@@ -42,14 +43,16 @@ class RememberMeListener implements ListenerInterface
* @param AuthenticationManagerInterface $authenticationManager
* @param LoggerInterface $logger
* @param EventDispatcherInterface $dispatcher
+ * @param bool $catchExceptions
*/
- public function __construct(SecurityContextInterface $securityContext, RememberMeServicesInterface $rememberMeServices, AuthenticationManagerInterface $authenticationManager, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
+ public function __construct(SecurityContextInterface $securityContext, RememberMeServicesInterface $rememberMeServices, AuthenticationManagerInterface $authenticationManager, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, $catchExceptions = true)
{
$this->securityContext = $securityContext;
$this->rememberMeServices = $rememberMeServices;
$this->authenticationManager = $authenticationManager;
$this->logger = $logger;
$this->dispatcher = $dispatcher;
+ $this->catchExceptions = $catchExceptions;
}
/**
@@ -90,6 +93,10 @@ class RememberMeListener implements ListenerInterface
}
$this->rememberMeServices->loginFail($request);
+
+ if (!$this->catchExceptions) {
+ throw $failed;
+ }
}
}
}
diff --git a/Http/Firewall/SimpleFormAuthenticationListener.php b/Http/Firewall/SimpleFormAuthenticationListener.php
index f79ce5c..20ce4f2 100644
--- a/Http/Firewall/SimpleFormAuthenticationListener.php
+++ b/Http/Firewall/SimpleFormAuthenticationListener.php
@@ -50,10 +50,13 @@ class SimpleFormAuthenticationListener extends AbstractAuthenticationListener
* successful, or failed authentication attempt
* @param LoggerInterface $logger A LoggerInterface instance
* @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
- * @param SimpleFormAuthenticatorInterface $simpleAuthenticator A SimpleFormAuthenticatorInterface instance
* @param CsrfTokenManagerInterface $csrfTokenManager A CsrfTokenManagerInterface instance
+ * @param SimpleFormAuthenticatorInterface $simpleAuthenticator A SimpleFormAuthenticatorInterface instance
+ *
+ * @throws \InvalidArgumentException In case no simple authenticator is provided
+ * @throws InvalidArgumentException In case an invalid CSRF token manager is passed
*/
- public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, CsrfTokenManagerInterface $csrfTokenManager = null, SimpleFormAuthenticatorInterface $simpleAuthenticator = null)
+ public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, $csrfTokenManager = null, SimpleFormAuthenticatorInterface $simpleAuthenticator = null)
{
if (!$simpleAuthenticator) {
throw new \InvalidArgumentException('Missing simple authenticator');
diff --git a/Http/Firewall/X509AuthenticationListener.php b/Http/Firewall/X509AuthenticationListener.php
index 5aabf75..9c07be1 100644
--- a/Http/Firewall/X509AuthenticationListener.php
+++ b/Http/Firewall/X509AuthenticationListener.php
@@ -41,10 +41,17 @@ class X509AuthenticationListener extends AbstractPreAuthenticatedListener
*/
protected function getPreAuthenticatedData(Request $request)
{
- if (!$request->server->has($this->userKey)) {
- throw new BadCredentialsException(sprintf('SSL key was not found: %s', $this->userKey));
+ $user = null;
+ if ($request->server->has($this->userKey)) {
+ $user = $request->server->get($this->userKey);
+ } elseif ($request->server->has($this->credentialKey) && preg_match('#/emailAddress=(.+\@.+\..+)(/|$)#', $request->server->get($this->credentialKey), $matches)) {
+ $user = $matches[1];
}
- return array($request->server->get($this->userKey), $request->server->get($this->credentialKey, ''));
+ if (null === $user) {
+ throw new BadCredentialsException(sprintf('SSL credentials not found: %s, %s', $this->userKey, $this->credentialKey));
+ }
+
+ return array($user, $request->server->get($this->credentialKey, ''));
}
}
diff --git a/Http/FirewallMap.php b/Http/FirewallMap.php
index 0554bed..1bb73bd 100644
--- a/Http/FirewallMap.php
+++ b/Http/FirewallMap.php
@@ -36,7 +36,7 @@ class FirewallMap implements FirewallMapInterface
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function getListeners(Request $request)
{
diff --git a/Http/HttpUtils.php b/Http/HttpUtils.php
index 422c8ce..451c12c 100644
--- a/Http/HttpUtils.php
+++ b/Http/HttpUtils.php
@@ -53,7 +53,7 @@ class HttpUtils
*
* @param Request $request A Request instance
* @param string $path A path (an absolute path (/foo), an absolute URL (http://...), or a route name (foo))
- * @param integer $status The status code
+ * @param int $status The status code
*
* @return RedirectResponse A RedirectResponse instance
*/
@@ -96,7 +96,7 @@ class HttpUtils
* @param Request $request A Request instance
* @param string $path A path (an absolute path (/foo), an absolute URL (http://...), or a route name (foo))
*
- * @return Boolean true if the path is the same as the one from the Request, false otherwise
+ * @return bool true if the path is the same as the one from the Request, false otherwise
*/
public function checkRequestPath(Request $request, $path)
{
diff --git a/Http/Logout/DefaultLogoutSuccessHandler.php b/Http/Logout/DefaultLogoutSuccessHandler.php
index 70f15cf..48626b0 100644
--- a/Http/Logout/DefaultLogoutSuccessHandler.php
+++ b/Http/Logout/DefaultLogoutSuccessHandler.php
@@ -37,7 +37,7 @@ class DefaultLogoutSuccessHandler implements LogoutSuccessHandlerInterface
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function onLogoutSuccess(Request $request)
{
diff --git a/Http/README.md b/Http/README.md
index c0760d4..e19af42 100644
--- a/Http/README.md
+++ b/Http/README.md
@@ -11,7 +11,7 @@ Resources
Documentation:
-http://symfony.com/doc/2.5/book/security.html
+http://symfony.com/doc/2.6/book/security.html
Tests
-----
diff --git a/Http/RememberMe/AbstractRememberMeServices.php b/Http/RememberMe/AbstractRememberMeServices.php
index 740d3d6..b868dae 100644
--- a/Http/RememberMe/AbstractRememberMeServices.php
+++ b/Http/RememberMe/AbstractRememberMeServices.php
@@ -142,8 +142,6 @@ abstract class AbstractRememberMeServices implements RememberMeServicesInterface
}
$this->cancelCookie($request);
-
- return null;
}
/**
@@ -295,7 +293,7 @@ abstract class AbstractRememberMeServices implements RememberMeServicesInterface
*
* @param Request $request
*
- * @return Boolean
+ * @return bool
*/
protected function isRememberMeRequested(Request $request)
{
@@ -305,7 +303,7 @@ abstract class AbstractRememberMeServices implements RememberMeServicesInterface
$parameter = $request->get($this->options['remember_me_parameter'], null, true);
- if ($parameter === null && null !== $this->logger) {
+ if (null === $parameter && null !== $this->logger) {
$this->logger->debug(sprintf('Did not send remember-me cookie (remember-me parameter "%s" was not sent).', $this->options['remember_me_parameter']));
}
diff --git a/Http/RememberMe/PersistentTokenBasedRememberMeServices.php b/Http/RememberMe/PersistentTokenBasedRememberMeServices.php
index 6500bfd..12478dc 100644
--- a/Http/RememberMe/PersistentTokenBasedRememberMeServices.php
+++ b/Http/RememberMe/PersistentTokenBasedRememberMeServices.php
@@ -62,7 +62,7 @@ class PersistentTokenBasedRememberMeServices extends AbstractRememberMeServices
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
protected function cancelCookie(Request $request)
{
@@ -79,7 +79,7 @@ class PersistentTokenBasedRememberMeServices extends AbstractRememberMeServices
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
protected function processAutoLoginCookie(array $cookieParts, Request $request)
{
@@ -117,7 +117,7 @@ class PersistentTokenBasedRememberMeServices extends AbstractRememberMeServices
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
protected function onLoginSuccess(Request $request, Response $response, TokenInterface $token)
{
diff --git a/Http/RememberMe/ResponseListener.php b/Http/RememberMe/ResponseListener.php
index 6087587..2253c5d 100644
--- a/Http/RememberMe/ResponseListener.php
+++ b/Http/RememberMe/ResponseListener.php
@@ -36,7 +36,7 @@ class ResponseListener implements EventSubscriberInterface
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public static function getSubscribedEvents()
{
diff --git a/Http/RememberMe/TokenBasedRememberMeServices.php b/Http/RememberMe/TokenBasedRememberMeServices.php
index 6fd6bc4..32a0df0 100644
--- a/Http/RememberMe/TokenBasedRememberMeServices.php
+++ b/Http/RememberMe/TokenBasedRememberMeServices.php
@@ -28,7 +28,7 @@ use Symfony\Component\Security\Core\Util\StringUtils;
class TokenBasedRememberMeServices extends AbstractRememberMeServices
{
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
protected function processAutoLoginCookie(array $cookieParts, Request $request)
{
@@ -66,7 +66,7 @@ class TokenBasedRememberMeServices extends AbstractRememberMeServices
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
protected function onLoginSuccess(Request $request, Response $response, TokenInterface $token)
{
@@ -92,7 +92,7 @@ class TokenBasedRememberMeServices extends AbstractRememberMeServices
*
* @param string $class
* @param string $username The username
- * @param integer $expires The Unix timestamp when the cookie expires
+ * @param int $expires The Unix timestamp when the cookie expires
* @param string $password The encoded password
*
* @throws \RuntimeException if username contains invalid chars
@@ -105,7 +105,7 @@ class TokenBasedRememberMeServices extends AbstractRememberMeServices
$class,
base64_encode($username),
$expires,
- $this->generateCookieHash($class, $username, $expires, $password)
+ $this->generateCookieHash($class, $username, $expires, $password),
));
}
@@ -114,7 +114,7 @@ class TokenBasedRememberMeServices extends AbstractRememberMeServices
*
* @param string $class
* @param string $username The username
- * @param integer $expires The Unix timestamp when the cookie expires
+ * @param int $expires The Unix timestamp when the cookie expires
* @param string $password The encoded password
*
* @throws \RuntimeException when the private key is empty
diff --git a/Http/Session/SessionAuthenticationStrategy.php b/Http/Session/SessionAuthenticationStrategy.php
index e9c9826..17160a1 100644
--- a/Http/Session/SessionAuthenticationStrategy.php
+++ b/Http/Session/SessionAuthenticationStrategy.php
@@ -38,7 +38,7 @@ class SessionAuthenticationStrategy implements SessionAuthenticationStrategyInte
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function onAuthentication(Request $request, TokenInterface $token)
{
diff --git a/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php b/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php
index b775588..4d1847d 100644
--- a/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php
+++ b/Http/Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php
@@ -43,7 +43,7 @@ class DefaultAuthenticationSuccessHandlerTest extends \PHPUnit_Framework_TestCas
{
$options = array(
'always_use_default_target_path' => true,
- 'default_target_path' => '/dashboard'
+ 'default_target_path' => '/dashboard',
);
$response = $this->expectRedirectResponse('/dashboard');
diff --git a/Http/Tests/EntryPoint/RetryAuthenticationEntryPointTest.php b/Http/Tests/EntryPoint/RetryAuthenticationEntryPointTest.php
index f4e5425..ff5fbc2 100644
--- a/Http/Tests/EntryPoint/RetryAuthenticationEntryPointTest.php
+++ b/Http/Tests/EntryPoint/RetryAuthenticationEntryPointTest.php
@@ -39,26 +39,26 @@ class RetryAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase
80,
443,
Request::create('http://localhost/foo/bar?baz=bat'),
- 'https://localhost/foo/bar?baz=bat'
+ 'https://localhost/foo/bar?baz=bat',
),
array(
80,
443,
Request::create('https://localhost/foo/bar?baz=bat'),
- 'http://localhost/foo/bar?baz=bat'
+ 'http://localhost/foo/bar?baz=bat',
),
array(
80,
123,
Request::create('http://localhost/foo/bar?baz=bat'),
- 'https://localhost:123/foo/bar?baz=bat'
+ 'https://localhost:123/foo/bar?baz=bat',
),
array(
8080,
443,
Request::create('https://localhost/foo/bar?baz=bat'),
- 'http://localhost:8080/foo/bar?baz=bat'
- )
+ 'http://localhost:8080/foo/bar?baz=bat',
+ ),
);
}
}
diff --git a/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php b/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php
index 57a91cf..6e34532 100644
--- a/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php
+++ b/Http/Tests/Firewall/AbstractPreAuthenticatedListenerTest.php
@@ -49,7 +49,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array(
$context,
$authenticationManager,
- 'TheProviderKey'
+ 'TheProviderKey',
));
$listener
->expects($this->once())
@@ -95,7 +95,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array(
$context,
$authenticationManager,
- 'TheProviderKey'
+ 'TheProviderKey',
));
$listener
->expects($this->once())
@@ -143,7 +143,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array(
$context,
$authenticationManager,
- 'TheProviderKey'
+ 'TheProviderKey',
));
$listener
->expects($this->once())
@@ -184,7 +184,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array(
$context,
$authenticationManager,
- 'TheProviderKey'
+ 'TheProviderKey',
));
$listener
->expects($this->once())
@@ -233,7 +233,7 @@ class AbstractPreAuthenticatedListenerTest extends \PHPUnit_Framework_TestCase
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array(
$context,
$authenticationManager,
- 'TheProviderKey'
+ 'TheProviderKey',
));
$listener
->expects($this->once())
diff --git a/Http/Tests/Firewall/BasicAuthenticationListenerTest.php b/Http/Tests/Firewall/BasicAuthenticationListenerTest.php
index eb51f5f..4080485 100644
--- a/Http/Tests/Firewall/BasicAuthenticationListenerTest.php
+++ b/Http/Tests/Firewall/BasicAuthenticationListenerTest.php
@@ -24,7 +24,7 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
{
$request = new Request(array(), array(), array(), array(), array(), array(
'PHP_AUTH_USER' => 'TheUsername',
- 'PHP_AUTH_PW' => 'ThePassword'
+ 'PHP_AUTH_PW' => 'ThePassword',
));
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
@@ -70,7 +70,7 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
{
$request = new Request(array(), array(), array(), array(), array(), array(
'PHP_AUTH_USER' => 'TheUsername',
- 'PHP_AUTH_PW' => 'ThePassword'
+ 'PHP_AUTH_PW' => 'ThePassword',
));
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
@@ -199,7 +199,7 @@ class BasicAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
{
$request = new Request(array(), array(), array(), array(), array(), array(
'PHP_AUTH_USER' => 'TheUsername',
- 'PHP_AUTH_PW' => 'ThePassword'
+ 'PHP_AUTH_PW' => 'ThePassword',
));
$token = new PreAuthenticatedToken('TheUser', 'TheCredentials', 'TheProviderKey', array('ROLE_FOO'));
diff --git a/Http/Tests/Firewall/ContextListenerTest.php b/Http/Tests/Firewall/ContextListenerTest.php
index c153fd5..d6bc5b4 100644
--- a/Http/Tests/Firewall/ContextListenerTest.php
+++ b/Http/Tests/Firewall/ContextListenerTest.php
@@ -174,7 +174,7 @@ class ContextListenerTest extends \PHPUnit_Framework_TestCase
return array(
array(serialize(new \__PHP_Incomplete_Class())),
array(serialize(null)),
- array(null)
+ array(null),
);
}
diff --git a/Http/Tests/Firewall/DigestDataTest.php b/Http/Tests/Firewall/DigestDataTest.php
index 86a5327..a7c8d49 100644
--- a/Http/Tests/Firewall/DigestDataTest.php
+++ b/Http/Tests/Firewall/DigestDataTest.php
@@ -18,9 +18,9 @@ class DigestDataTest extends \PHPUnit_Framework_TestCase
public function testGetResponse()
{
$digestAuth = new DigestData(
- 'username="user", realm="Welcome, robot!", ' .
- 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", ' .
- 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' .
+ 'username="user", realm="Welcome, robot!", '.
+ 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", '.
+ 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", '.
'response="b52938fc9e6d7c01be7702ece9031b42"'
);
@@ -30,9 +30,9 @@ class DigestDataTest extends \PHPUnit_Framework_TestCase
public function testGetUsername()
{
$digestAuth = new DigestData(
- 'username="user", realm="Welcome, robot!", ' .
- 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", ' .
- 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' .
+ 'username="user", realm="Welcome, robot!", '.
+ 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", '.
+ 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", '.
'response="b52938fc9e6d7c01be7702ece9031b42"'
);
@@ -42,9 +42,9 @@ class DigestDataTest extends \PHPUnit_Framework_TestCase
public function testGetUsernameWithQuote()
{
$digestAuth = new DigestData(
- 'username="\"user\"", realm="Welcome, robot!", ' .
- 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", ' .
- 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' .
+ 'username="\"user\"", realm="Welcome, robot!", '.
+ 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", '.
+ 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", '.
'response="b52938fc9e6d7c01be7702ece9031b42"'
);
@@ -54,9 +54,9 @@ class DigestDataTest extends \PHPUnit_Framework_TestCase
public function testGetUsernameWithQuoteAndEscape()
{
$digestAuth = new DigestData(
- 'username="\"u\\\\\"ser\"", realm="Welcome, robot!", ' .
- 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", ' .
- 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' .
+ 'username="\"u\\\\\"ser\"", realm="Welcome, robot!", '.
+ 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", '.
+ 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", '.
'response="b52938fc9e6d7c01be7702ece9031b42"'
);
@@ -66,9 +66,9 @@ class DigestDataTest extends \PHPUnit_Framework_TestCase
public function testGetUsernameWithSingleQuote()
{
$digestAuth = new DigestData(
- 'username="\"u\'ser\"", realm="Welcome, robot!", ' .
- 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", ' .
- 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' .
+ 'username="\"u\'ser\"", realm="Welcome, robot!", '.
+ 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", '.
+ 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", '.
'response="b52938fc9e6d7c01be7702ece9031b42"'
);
@@ -78,9 +78,9 @@ class DigestDataTest extends \PHPUnit_Framework_TestCase
public function testGetUsernameWithSingleQuoteAndEscape()
{
$digestAuth = new DigestData(
- 'username="\"u\\\'ser\"", realm="Welcome, robot!", ' .
- 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", ' .
- 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' .
+ 'username="\"u\\\'ser\"", realm="Welcome, robot!", '.
+ 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", '.
+ 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", '.
'response="b52938fc9e6d7c01be7702ece9031b42"'
);
@@ -90,9 +90,9 @@ class DigestDataTest extends \PHPUnit_Framework_TestCase
public function testGetUsernameWithEscape()
{
$digestAuth = new DigestData(
- 'username="\"u\\ser\"", realm="Welcome, robot!", ' .
- 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", ' .
- 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' .
+ 'username="\"u\\ser\"", realm="Welcome, robot!", '.
+ 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", '.
+ 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", '.
'response="b52938fc9e6d7c01be7702ece9031b42"'
);
@@ -106,8 +106,8 @@ class DigestDataTest extends \PHPUnit_Framework_TestCase
$nonce = base64_encode($time.':'.md5($time.':'.$key));
$digestAuth = new DigestData(
- 'username="user", realm="Welcome, robot!", nonce="'.$nonce.'", ' .
- 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' .
+ 'username="user", realm="Welcome, robot!", nonce="'.$nonce.'", '.
+ 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", '.
'response="b52938fc9e6d7c01be7702ece9031b42"'
);
@@ -146,8 +146,8 @@ class DigestDataTest extends \PHPUnit_Framework_TestCase
$nonce = base64_encode($time.':'.md5($time.':'.$key));
$digestAuth = new DigestData(
- 'username="user", realm="Welcome, robot!", nonce="'.$nonce.'", ' .
- 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' .
+ 'username="user", realm="Welcome, robot!", nonce="'.$nonce.'", '.
+ 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", '.
'response="b52938fc9e6d7c01be7702ece9031b42"'
);
diff --git a/Http/Tests/Firewall/RememberMeListenerTest.php b/Http/Tests/Firewall/RememberMeListenerTest.php
index 9506692..68dfc14 100644
--- a/Http/Tests/Firewall/RememberMeListenerTest.php
+++ b/Http/Tests/Firewall/RememberMeListenerTest.php
@@ -14,12 +14,13 @@ namespace Symfony\Component\Security\Http\Tests\Firewall;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Http\Firewall\RememberMeListener;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Security\Http\SecurityEvents;
class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
{
public function testOnCoreSecurityDoesNotTryToPopulateNonEmptySecurityContext()
{
- list($listener, $context, $service,,) = $this->getListener();
+ list($listener, $context,,,,) = $this->getListener();
$context
->expects($this->once())
@@ -99,6 +100,48 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
$listener->handle($event);
}
+ /**
+ * @expectedException Symfony\Component\Security\Core\Exception\AuthenticationException
+ * @expectedExceptionMessage Authentication failed.
+ */
+ public function testOnCoreSecurityIgnoresAuthenticationOptionallyRethrowsExceptionThrownAuthenticationManagerImplementation()
+ {
+ list($listener, $context, $service, $manager,) = $this->getListener(false, false);
+
+ $context
+ ->expects($this->once())
+ ->method('getToken')
+ ->will($this->returnValue(null))
+ ;
+
+ $service
+ ->expects($this->once())
+ ->method('autoLogin')
+ ->will($this->returnValue($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')))
+ ;
+
+ $service
+ ->expects($this->once())
+ ->method('loginFail')
+ ;
+
+ $exception = new AuthenticationException('Authentication failed.');
+ $manager
+ ->expects($this->once())
+ ->method('authenticate')
+ ->will($this->throwException($exception))
+ ;
+
+ $event = $this->getGetResponseEvent();
+ $event
+ ->expects($this->once())
+ ->method('getRequest')
+ ->will($this->returnValue(new Request()))
+ ;
+
+ $listener->handle($event);
+ }
+
public function testOnCoreSecurity()
{
list($listener, $context, $service, $manager,) = $this->getListener();
@@ -138,6 +181,55 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
$listener->handle($event);
}
+ public function testOnCoreSecurityInteractiveLoginEventIsDispatchedIfDispatcherIsPresent()
+ {
+ list($listener, $context, $service, $manager,, $dispatcher) = $this->getListener(true);
+
+ $context
+ ->expects($this->once())
+ ->method('getToken')
+ ->will($this->returnValue(null))
+ ;
+
+ $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $service
+ ->expects($this->once())
+ ->method('autoLogin')
+ ->will($this->returnValue($token))
+ ;
+
+ $context
+ ->expects($this->once())
+ ->method('setToken')
+ ->with($this->equalTo($token))
+ ;
+
+ $manager
+ ->expects($this->once())
+ ->method('authenticate')
+ ->will($this->returnValue($token))
+ ;
+
+ $event = $this->getGetResponseEvent();
+ $request = new Request();
+ $event
+ ->expects($this->once())
+ ->method('getRequest')
+ ->will($this->returnValue($request))
+ ;
+
+ $dispatcher
+ ->expects($this->once())
+ ->method('dispatch')
+ ->with(
+ SecurityEvents::INTERACTIVE_LOGIN,
+ $this->isInstanceOf('Symfony\Component\Security\Http\Event\InteractiveLoginEvent')
+ )
+ ;
+
+ $listener->handle($event);
+ }
+
protected function getGetResponseEvent()
{
return $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
@@ -148,16 +240,18 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
return $this->getMock('Symfony\Component\HttpKernel\Event\FilterResponseEvent', array(), array(), '', false);
}
- protected function getListener()
+ protected function getListener($withDispatcher = false, $catchExceptions = true)
{
$listener = new RememberMeListener(
$context = $this->getContext(),
$service = $this->getService(),
$manager = $this->getManager(),
- $logger = $this->getLogger()
+ $logger = $this->getLogger(),
+ $dispatcher = ($withDispatcher ? $this->getDispatcher() : null),
+ $catchExceptions
);
- return array($listener, $context, $service, $manager, $logger);
+ return array($listener, $context, $service, $manager, $logger, $dispatcher);
}
protected function getLogger()
@@ -177,8 +271,11 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
protected function getContext()
{
- return $this->getMockBuilder('Symfony\Component\Security\Core\SecurityContext')
- ->disableOriginalConstructor()
- ->getMock();
+ return $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
+ }
+
+ protected function getDispatcher()
+ {
+ return $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
}
}
diff --git a/Http/Tests/Firewall/SwitchUserListenerTest.php b/Http/Tests/Firewall/SwitchUserListenerTest.php
index 110e05c..9e149a2 100644
--- a/Http/Tests/Firewall/SwitchUserListenerTest.php
+++ b/Http/Tests/Firewall/SwitchUserListenerTest.php
@@ -157,7 +157,7 @@ class SwitchUserListenerTest extends \PHPUnit_Framework_TestCase
$this->securityContext->expects($this->any())->method('getToken')->will($this->returnValue($token));
$this->request->expects($this->any())->method('get')->with('_switch_user')->will($this->returnValue('kuba'));
$this->request->query->expects($this->once())->method('remove', '_switch_user');
- $this->request->query->expects($this->any())->method('all')->will($this->returnValue(array('page'=>3,'section'=>2)));
+ $this->request->query->expects($this->any())->method('all')->will($this->returnValue(array('page' => 3,'section' => 2)));
$this->request->expects($this->any())->method('getUri')->will($this->returnValue('/'));
$this->request->server->expects($this->once())->method('set')->with('QUERY_STRING', 'page=3&section=2');
diff --git a/Http/Tests/Firewall/X509AuthenticationListenerTest.php b/Http/Tests/Firewall/X509AuthenticationListenerTest.php
index 7725f4b..7f2da3e 100644
--- a/Http/Tests/Firewall/X509AuthenticationListenerTest.php
+++ b/Http/Tests/Firewall/X509AuthenticationListenerTest.php
@@ -35,11 +35,7 @@ class X509AuthenticationListenerTest extends \PHPUnit_Framework_TestCase
$authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
- $listener = new X509AuthenticationListener(
- $context,
- $authenticationManager,
- 'TheProviderKey'
- );
+ $listener = new X509AuthenticationListener($context, $authenticationManager, 'TheProviderKey');
$method = new \ReflectionMethod($listener, 'getPreAuthenticatedData');
$method->setAccessible(true);
@@ -57,9 +53,38 @@ class X509AuthenticationListenerTest extends \PHPUnit_Framework_TestCase
}
/**
+ * @dataProvider dataProviderGetPreAuthenticatedDataNoUser
+ */
+ public function testGetPreAuthenticatedDataNoUser($emailAddress)
+ {
+ $credentials = 'CN=Sample certificate DN/emailAddress='.$emailAddress;
+ $request = new Request(array(), array(), array(), array(), array(), array('SSL_CLIENT_S_DN' => $credentials));
+
+ $context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
+
+ $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
+
+ $listener = new X509AuthenticationListener($context, $authenticationManager, 'TheProviderKey');
+
+ $method = new \ReflectionMethod($listener, 'getPreAuthenticatedData');
+ $method->setAccessible(true);
+
+ $result = $method->invokeArgs($listener, array($request));
+ $this->assertSame($result, array($emailAddress, $credentials));
+ }
+
+ public static function dataProviderGetPreAuthenticatedDataNoUser()
+ {
+ return array(
+ 'basicEmailAddress' => array('cert@example.com'),
+ 'emailAddressWithPlusSign' => array('cert+something@example.com'),
+ );
+ }
+
+ /**
* @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
*/
- public function testGetPreAuthenticatedDataNoUser()
+ public function testGetPreAuthenticatedDataNoData()
{
$request = new Request(array(), array(), array(), array(), array(), array());
@@ -67,11 +92,7 @@ class X509AuthenticationListenerTest extends \PHPUnit_Framework_TestCase
$authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
- $listener = new X509AuthenticationListener(
- $context,
- $authenticationManager,
- 'TheProviderKey'
- );
+ $listener = new X509AuthenticationListener($context, $authenticationManager, 'TheProviderKey');
$method = new \ReflectionMethod($listener, 'getPreAuthenticatedData');
$method->setAccessible(true);
@@ -85,19 +106,13 @@ class X509AuthenticationListenerTest extends \PHPUnit_Framework_TestCase
$request = new Request(array(), array(), array(), array(), array(), array(
'TheUserKey' => 'TheUser',
- 'TheCredentialsKey' => 'TheCredentials'
+ 'TheCredentialsKey' => 'TheCredentials',
));
$context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
$authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
- $listener = new X509AuthenticationListener(
- $context,
- $authenticationManager,
- 'TheProviderKey',
- 'TheUserKey',
- 'TheCredentialsKey'
- );
+ $listener = new X509AuthenticationListener($context, $authenticationManager, 'TheProviderKey', 'TheUserKey', 'TheCredentialsKey');
$method = new \ReflectionMethod($listener, 'getPreAuthenticatedData');
$method->setAccessible(true);
diff --git a/Http/Tests/FirewallTest.php b/Http/Tests/FirewallTest.php
index 67f4f15..9994737 100644
--- a/Http/Tests/FirewallTest.php
+++ b/Http/Tests/FirewallTest.php
@@ -73,7 +73,7 @@ class FirewallTest extends \PHPUnit_Framework_TestCase
array(
$this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'),
$this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false),
- HttpKernelInterface::MASTER_REQUEST
+ HttpKernelInterface::MASTER_REQUEST,
)
);
$event
diff --git a/Http/Tests/HttpUtilsTest.php b/Http/Tests/HttpUtilsTest.php
index 90380ea..5cac504 100644
--- a/Http/Tests/HttpUtilsTest.php
+++ b/Http/Tests/HttpUtilsTest.php
@@ -128,7 +128,7 @@ class HttpUtilsTest extends \PHPUnit_Framework_TestCase
return array(
array(SecurityContextInterface::AUTHENTICATION_ERROR),
array(SecurityContextInterface::ACCESS_DENIED_ERROR),
- array(SecurityContextInterface::LAST_USERNAME)
+ array(SecurityContextInterface::LAST_USERNAME),
);
}
diff --git a/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php b/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php
index 927b771..c3d9260 100644
--- a/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php
+++ b/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php
@@ -243,7 +243,7 @@ class AbstractRememberMeServicesTest extends \PHPUnit_Framework_TestCase
}
return $this->getMockForAbstractClass('Symfony\Component\Security\Http\RememberMe\AbstractRememberMeServices', array(
- array($userProvider), 'fookey', 'fookey', $options, $logger
+ array($userProvider), 'fookey', 'fookey', $options, $logger,
));
}
diff --git a/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php b/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php
index 098f5b6..a490e9a 100644
--- a/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php
+++ b/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php
@@ -117,7 +117,8 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_Test
try {
$service->autoLogin($request);
$this->fail('Expected CookieTheftException was not thrown.');
- } catch (CookieTheftException $theft) { }
+ } catch (CookieTheftException $theft) {
+ }
$this->assertTrue($request->attributes->has(RememberMeServicesInterface::COOKIE_ATTR_NAME));
}
diff --git a/Http/Tests/RememberMe/ResponseListenerTest.php b/Http/Tests/RememberMe/ResponseListenerTest.php
index 3c228b4..9bb84a2 100644
--- a/Http/Tests/RememberMe/ResponseListenerTest.php
+++ b/Http/Tests/RememberMe/ResponseListenerTest.php
@@ -24,7 +24,7 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
$cookie = new Cookie('rememberme');
$request = $this->getRequest(array(
- RememberMeServicesInterface::COOKIE_ATTR_NAME => $cookie
+ RememberMeServicesInterface::COOKIE_ATTR_NAME => $cookie,
));
$response = $this->getResponse();
diff --git a/Http/composer.json b/Http/composer.json
index c544ad1..8129523 100644
--- a/Http/composer.json
+++ b/Http/composer.json
@@ -38,7 +38,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
- "dev-master": "2.5-dev"
+ "dev-master": "2.6-dev"
}
}
}