diff --git a/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md b/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md
index 724254de78b4d..06d56b3361501 100644
--- a/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md
+++ b/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md
@@ -1,6 +1,11 @@
CHANGELOG
=========
+2.4.0
+-----
+
+ * Added 'host' option to firewall configuration
+
2.3.0
-----
diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php
index 2e1be8c6947d7..5041479704642 100644
--- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php
+++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php
@@ -199,6 +199,7 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto
$firewallNodeBuilder
->scalarNode('pattern')->end()
+ ->scalarNode('host')->end()
->booleanNode('security')->defaultTrue()->end()
->scalarNode('request_matcher')->end()
->scalarNode('access_denied_url')->end()
diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
index ad75ac14a3f04..d87a890f5e5f1 100644
--- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
+++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
@@ -244,8 +244,10 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
$matcher = null;
if (isset($firewall['request_matcher'])) {
$matcher = new Reference($firewall['request_matcher']);
- } elseif (isset($firewall['pattern'])) {
- $matcher = $this->createRequestMatcher($container, $firewall['pattern']);
+ } elseif (isset($firewall['pattern']) || isset($firewall['host'])) {
+ $pattern = isset($firewall['pattern']) ? $firewall['pattern'] : null;
+ $host = isset($firewall['host']) ? $firewall['host'] : null;
+ $matcher = $this->createRequestMatcher($container, $pattern, $host);
}
// Security disabled?
diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php
index 2e55643c7015f..d5af681b3331d 100644
--- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php
+++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php
@@ -85,9 +85,41 @@ public function testFirewalls()
'security.access_listener',
'security.authentication.switchuser_listener.secure',
),
+ array(
+ 'security.channel_listener',
+ 'security.context_listener.0',
+ 'security.authentication.listener.basic.host',
+ 'security.authentication.listener.anonymous.host',
+ 'security.access_listener',
+ ),
), $listeners);
}
+ public function testFirewallRequestMatchers()
+ {
+ $container = $this->getContainer('container1');
+
+ $arguments = $container->getDefinition('security.firewall.map')->getArguments();
+ $matchers = array();
+
+ foreach ($arguments[1] as $reference) {
+ if ($reference instanceof Reference) {
+ $definition = $container->getDefinition((string) $reference);
+ $matchers[] = $definition->getArguments();
+ }
+ }
+
+ $this->assertEquals(array(
+ array(
+ '/login',
+ ),
+ array(
+ '/test',
+ 'foo\\.example\\.org',
+ ),
+ ), $matchers);
+ }
+
public function testAccess()
{
$container = $this->getContainer('container1');
diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/container1.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/container1.php
index bb79da3fb05a6..d91d604a6a12a 100644
--- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/container1.php
+++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/container1.php
@@ -71,6 +71,12 @@
'x509' => true,
'logout' => true,
),
+ 'host' => array(
+ 'pattern' => '/test',
+ 'host' => 'foo\\.example\\.org',
+ 'anonymous' => true,
+ 'http_basic' => true,
+ ),
),
'access_control' => array(
diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/container1.xml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/container1.xml
index cb452e9316693..9da4ad937f48a 100644
--- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/container1.xml
+++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/container1.xml
@@ -57,6 +57,11 @@
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: