summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Acl/README.md2
-rw-r--r--Acl/composer.json2
-rw-r--r--Acl/phpunit.xml.dist6
-rw-r--r--CHANGELOG.md5
-rw-r--r--Core/README.md2
-rw-r--r--Core/composer.json2
-rw-r--r--Core/phpunit.xml.dist6
-rw-r--r--Csrf/README.md2
-rw-r--r--Csrf/composer.json2
-rw-r--r--Csrf/phpunit.xml.dist6
-rw-r--r--Http/Firewall/SimplePreAuthenticationListener.php23
-rw-r--r--Http/README.md2
-rw-r--r--Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php136
-rw-r--r--Http/composer.json2
-rw-r--r--Http/phpunit.xml.dist6
-rw-r--r--README.md2
-rw-r--r--composer.json2
-rw-r--r--phpunit.xml.dist4
18 files changed, 195 insertions, 17 deletions
diff --git a/Acl/README.md b/Acl/README.md
index bb2d4d7..4b68d90 100644
--- a/Acl/README.md
+++ b/Acl/README.md
@@ -11,7 +11,7 @@ Resources
Documentation:
-http://symfony.com/doc/2.6/book/security.html
+http://symfony.com/doc/2.7/book/security.html
Tests
-----
diff --git a/Acl/composer.json b/Acl/composer.json
index fb25b5d..8f65f50 100644
--- a/Acl/composer.json
+++ b/Acl/composer.json
@@ -36,7 +36,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
- "dev-master": "2.6-dev"
+ "dev-master": "2.7-dev"
}
}
}
diff --git a/Acl/phpunit.xml.dist b/Acl/phpunit.xml.dist
index 6520948..20d1b80 100644
--- a/Acl/phpunit.xml.dist
+++ b/Acl/phpunit.xml.dist
@@ -11,6 +11,12 @@
syntaxCheck="false"
bootstrap="vendor/autoload.php"
>
+ <php>
+ <!-- Disable E_USER_DEPRECATED until 3.0 -->
+ <!-- php -r 'echo -1 & ~E_USER_DEPRECATED;' -->
+ <ini name="error_reporting" value="-16385"/>
+ </php>
+
<testsuites>
<testsuite name="Symfony Security Component ACL Test Suite">
<directory>./Tests/</directory>
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c08d5cc..677c185 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,11 @@
CHANGELOG
=========
+2.7.0
+-----
+
+* Added the triggering of the `Symfony\Component\Security\Http\SecurityEvents::INTERACTIVE_LOGIN` in `Symfony\Component\Security\Http\Firewall\SimplePreAuthenticationListener`
+
2.6.0
-----
diff --git a/Core/README.md b/Core/README.md
index 66c323e..8e05a92 100644
--- a/Core/README.md
+++ b/Core/README.md
@@ -11,7 +11,7 @@ Resources
Documentation:
-http://symfony.com/doc/2.6/book/security.html
+http://symfony.com/doc/2.7/book/security.html
Tests
-----
diff --git a/Core/composer.json b/Core/composer.json
index c6923bf..2fc50f4 100644
--- a/Core/composer.json
+++ b/Core/composer.json
@@ -41,7 +41,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
- "dev-master": "2.6-dev"
+ "dev-master": "2.7-dev"
}
}
}
diff --git a/Core/phpunit.xml.dist b/Core/phpunit.xml.dist
index f085b72..7a5f7da 100644
--- a/Core/phpunit.xml.dist
+++ b/Core/phpunit.xml.dist
@@ -11,6 +11,12 @@
syntaxCheck="false"
bootstrap="vendor/autoload.php"
>
+ <php>
+ <!-- Disable E_USER_DEPRECATED until 3.0 -->
+ <!-- php -r 'echo -1 & ~E_USER_DEPRECATED;' -->
+ <ini name="error_reporting" value="-16385"/>
+ </php>
+
<testsuites>
<testsuite name="Symfony Security Component Core Test Suite">
<directory>./Tests/</directory>
diff --git a/Csrf/README.md b/Csrf/README.md
index 89ed66c..30d7bb2 100644
--- a/Csrf/README.md
+++ b/Csrf/README.md
@@ -9,7 +9,7 @@ Resources
Documentation:
-http://symfony.com/doc/2.6/book/security.html
+http://symfony.com/doc/2.7/book/security.html
Tests
-----
diff --git a/Csrf/composer.json b/Csrf/composer.json
index 4daba5c..0ed6428 100644
--- a/Csrf/composer.json
+++ b/Csrf/composer.json
@@ -32,7 +32,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
- "dev-master": "2.6-dev"
+ "dev-master": "2.7-dev"
}
}
}
diff --git a/Csrf/phpunit.xml.dist b/Csrf/phpunit.xml.dist
index 0718c76..f6e9005 100644
--- a/Csrf/phpunit.xml.dist
+++ b/Csrf/phpunit.xml.dist
@@ -11,6 +11,12 @@
syntaxCheck="false"
bootstrap="vendor/autoload.php"
>
+ <php>
+ <!-- Disable E_USER_DEPRECATED until 3.0 -->
+ <!-- php -r 'echo -1 & ~E_USER_DEPRECATED;' -->
+ <ini name="error_reporting" value="-16385"/>
+ </php>
+
<testsuites>
<testsuite name="Symfony Security Component CSRF Test Suite">
<directory>./Tests/</directory>
diff --git a/Http/Firewall/SimplePreAuthenticationListener.php b/Http/Firewall/SimplePreAuthenticationListener.php
index e80cc98..5d954f3 100644
--- a/Http/Firewall/SimplePreAuthenticationListener.php
+++ b/Http/Firewall/SimplePreAuthenticationListener.php
@@ -21,6 +21,9 @@ use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
+use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
+use Symfony\Component\Security\Http\SecurityEvents;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* SimplePreAuthenticationListener implements simple proxying to an authenticator.
@@ -34,17 +37,19 @@ class SimplePreAuthenticationListener implements ListenerInterface
private $providerKey;
private $simpleAuthenticator;
private $logger;
+ private $dispatcher;
/**
* Constructor.
*
- * @param SecurityContextInterface $securityContext A SecurityContext instance
- * @param AuthenticationManagerInterface $authenticationManager An AuthenticationManagerInterface instance
- * @param string $providerKey
- * @param SimplePreAuthenticatorInterface $simpleAuthenticator A SimplePreAuthenticatorInterface instance
- * @param LoggerInterface $logger A LoggerInterface instance
+ * @param SecurityContextInterface $securityContext A SecurityContext instance
+ * @param AuthenticationManagerInterface $authenticationManager An AuthenticationManagerInterface instance
+ * @param string $providerKey
+ * @param SimplePreAuthenticatorInterface $simpleAuthenticator A SimplePreAuthenticatorInterface instance
+ * @param LoggerInterface $logger A LoggerInterface instance
+ * @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
*/
- public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, $providerKey, SimplePreAuthenticatorInterface $simpleAuthenticator, LoggerInterface $logger = null)
+ public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, $providerKey, SimplePreAuthenticatorInterface $simpleAuthenticator, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
{
if (empty($providerKey)) {
throw new \InvalidArgumentException('$providerKey must not be empty.');
@@ -55,6 +60,7 @@ class SimplePreAuthenticationListener implements ListenerInterface
$this->providerKey = $providerKey;
$this->simpleAuthenticator = $simpleAuthenticator;
$this->logger = $logger;
+ $this->dispatcher = $dispatcher;
}
/**
@@ -84,6 +90,11 @@ class SimplePreAuthenticationListener implements ListenerInterface
$token = $this->authenticationManager->authenticate($token);
$this->securityContext->setToken($token);
+
+ if (null !== $this->dispatcher) {
+ $loginEvent = new InteractiveLoginEvent($request, $token);
+ $this->dispatcher->dispatch(SecurityEvents::INTERACTIVE_LOGIN, $loginEvent);
+ }
} catch (AuthenticationException $e) {
$this->securityContext->setToken(null);
diff --git a/Http/README.md b/Http/README.md
index e19af42..35437f2 100644
--- a/Http/README.md
+++ b/Http/README.md
@@ -11,7 +11,7 @@ Resources
Documentation:
-http://symfony.com/doc/2.6/book/security.html
+http://symfony.com/doc/2.7/book/security.html
Tests
-----
diff --git a/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php b/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php
new file mode 100644
index 0000000..b4a4a34
--- /dev/null
+++ b/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php
@@ -0,0 +1,136 @@
+<?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\Tests\Firewall;
+
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Security\Core\Exception\AuthenticationException;
+use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
+use Symfony\Component\Security\Http\Firewall\SimplePreAuthenticationListener;
+use Symfony\Component\Security\Http\SecurityEvents;
+
+class SimplePreAuthenticationListenerTest extends \PHPUnit_Framework_TestCase
+{
+ private $authenticationManager;
+ private $dispatcher;
+ private $event;
+ private $logger;
+ private $request;
+ private $securityContext;
+ private $token;
+
+ public function testHandle()
+ {
+ $this->securityContext
+ ->expects($this->once())
+ ->method('setToken')
+ ->with($this->equalTo($this->token))
+ ;
+
+ $this->authenticationManager
+ ->expects($this->once())
+ ->method('authenticate')
+ ->with($this->equalTo($this->token))
+ ->will($this->returnValue($this->token))
+ ;
+
+ $simpleAuthenticator = $this->getMock('Symfony\Component\Security\Core\Authentication\SimplePreAuthenticatorInterface');
+ $simpleAuthenticator
+ ->expects($this->once())
+ ->method('createToken')
+ ->with($this->equalTo($this->request), $this->equalTo('secured_area'))
+ ->will($this->returnValue($this->token))
+ ;
+
+ $loginEvent = new InteractiveLoginEvent($this->request, $this->token);
+
+ $this->dispatcher
+ ->expects($this->once())
+ ->method('dispatch')
+ ->with($this->equalTo(SecurityEvents::INTERACTIVE_LOGIN), $this->equalTo($loginEvent))
+ ;
+
+ $listener = new SimplePreAuthenticationListener($this->securityContext, $this->authenticationManager, 'secured_area', $simpleAuthenticator, $this->logger, $this->dispatcher);
+
+ $listener->handle($this->event);
+ }
+
+ public function testHandlecatchAuthenticationException()
+ {
+ $exception = new AuthenticationException('Authentication failed.');
+
+ $this->authenticationManager
+ ->expects($this->once())
+ ->method('authenticate')
+ ->with($this->equalTo($this->token))
+ ->will($this->throwException($exception))
+ ;
+
+ $this->securityContext->expects($this->once())
+ ->method('setToken')
+ ->with($this->equalTo(null))
+ ;
+
+ $simpleAuthenticator = $this->getMock('Symfony\Component\Security\Core\Authentication\SimplePreAuthenticatorInterface');
+ $simpleAuthenticator
+ ->expects($this->once())
+ ->method('createToken')
+ ->with($this->equalTo($this->request), $this->equalTo('secured_area'))
+ ->will($this->returnValue($this->token))
+ ;
+
+ $listener = new SimplePreAuthenticationListener($this->securityContext, $this->authenticationManager, 'secured_area', $simpleAuthenticator, $this->logger, $this->dispatcher);
+
+ $listener->handle($this->event);
+ }
+
+ public function setUp()
+ {
+ $this->authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager')
+ ->disableOriginalConstructor()
+ ->getMock()
+ ;
+
+ $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
+
+ $this->request = new Request(array(), array(), array(), array(), array(), array());
+
+ $this->event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
+ $this->event
+ ->expects($this->any())
+ ->method('getRequest')
+ ->will($this->returnValue($this->request))
+ ;
+
+ $this->logger = $this->getMockBuilder('Symfony\Bridge\Monolog\Logger')
+ ->disableOriginalConstructor()
+ ->getMock()
+ ;
+
+ $this->securityContext = $this->getMockBuilder('Symfony\Component\Security\Core\SecurityContext')
+ ->disableOriginalConstructor()
+ ->getMock()
+ ;
+
+ $this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ }
+
+ public function tearDown()
+ {
+ $this->authenticationManager = null;
+ $this->dispatcher = null;
+ $this->event = null;
+ $this->logger = null;
+ $this->request = null;
+ $this->securityContext = null;
+ $this->token = null;
+ }
+}
diff --git a/Http/composer.json b/Http/composer.json
index ad04f44..58f443d 100644
--- a/Http/composer.json
+++ b/Http/composer.json
@@ -38,7 +38,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
- "dev-master": "2.6-dev"
+ "dev-master": "2.7-dev"
}
}
}
diff --git a/Http/phpunit.xml.dist b/Http/phpunit.xml.dist
index a735efd..58fe58e 100644
--- a/Http/phpunit.xml.dist
+++ b/Http/phpunit.xml.dist
@@ -11,6 +11,12 @@
syntaxCheck="false"
bootstrap="vendor/autoload.php"
>
+ <php>
+ <!-- Disable E_USER_DEPRECATED until 3.0 -->
+ <!-- php -r 'echo -1 & ~E_USER_DEPRECATED;' -->
+ <ini name="error_reporting" value="-16385"/>
+ </php>
+
<testsuites>
<testsuite name="Symfony Security Component HTTP Test Suite">
<directory>./Tests/</directory>
diff --git a/README.md b/README.md
index c799a5d..66c7d80 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ Resources
Documentation:
-http://symfony.com/doc/2.6/book/security.html
+http://symfony.com/doc/2.7/book/security.html
Tests
-----
diff --git a/composer.json b/composer.json
index 4c4ce3e..f1abdb3 100644
--- a/composer.json
+++ b/composer.json
@@ -54,7 +54,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
- "dev-master": "2.6-dev"
+ "dev-master": "2.7-dev"
}
}
}
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index f11fabe..7cbf08a 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -7,9 +7,11 @@
bootstrap="vendor/autoload.php"
>
<php>
- <!-- Silence E_USER_DEPRECATED (-16385 == -1 & ~E_USER_DEPRECATED) -->
+ <!-- Disable E_USER_DEPRECATED until 3.0 -->
+ <!-- php -r 'echo -1 & ~E_USER_DEPRECATED;' -->
<ini name="error_reporting" value="-16385"/>
</php>
+
<testsuites>
<testsuite name="Symfony Security Component Test Suite">
<directory>./Acl/Tests/</directory>