diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
index adfe5b235752b..73a1cef128dd8 100644
--- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
+++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
@@ -331,10 +331,10 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
// Provider id (take the first registered provider if none defined)
if (isset($firewall['provider'])) {
- $defaultProvider = $this->getUserProviderId($firewall['provider']);
- if (!in_array($defaultProvider, $providerIds, true)) {
+ if (!isset($providerIds[$normalizedName = str_replace('-', '_', $firewall['provider'])])) {
throw new InvalidConfigurationException(sprintf('Invalid firewall "%s": user provider "%s" not found.', $id, $firewall['provider']));
}
+ $defaultProvider = $providerIds[$normalizedName];
} else {
$defaultProvider = reset($providerIds);
}
@@ -491,10 +491,10 @@ private function createAuthenticationListeners($container, $id, $firewall, &$aut
if (isset($firewall[$key])) {
if (isset($firewall[$key]['provider'])) {
- if (!in_array($firewall[$key]['provider'], $providerIds, true)) {
+ if (!isset($providerIds[$normalizedName = str_replace('-', '_', $firewall[$key]['provider'])])) {
throw new InvalidConfigurationException(sprintf('Invalid firewall "%s": user provider "%s" not found.', $id, $firewall[$key]['provider']));
}
- $userProvider = $this->getUserProviderId($firewall[$key]['provider']);
+ $userProvider = $providerIds[$normalizedName];
} else {
$userProvider = $defaultProvider;
}
@@ -596,7 +596,7 @@ private function createUserProviders($config, ContainerBuilder $container)
$providerIds = array();
foreach ($config['providers'] as $name => $provider) {
$id = $this->createUserDaoProvider($name, $provider, $container);
- $providerIds[] = $id;
+ $providerIds[str_replace('-', '_', $name)] = $id;
}
return $providerIds;
diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php
index 202107a57abf2..1cb5a6acda066 100644
--- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php
+++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php
@@ -405,6 +405,18 @@ public function testFirewallListenerUndefinedProvider()
$this->getContainer('listener_undefined_provider');
}
+ public function testFirewallWithUserProvider()
+ {
+ $this->getContainer('firewall_provider');
+ $this->addToAssertionCount(1);
+ }
+
+ public function testFirewallListenerWithProvider()
+ {
+ $this->getContainer('listener_provider');
+ $this->addToAssertionCount(1);
+ }
+
protected function getContainer($file)
{
$file = $file.'.'.$this->getFileExtension();
diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/firewall_provider.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/firewall_provider.php
new file mode 100644
index 0000000000000..ff9d9f6b89df6
--- /dev/null
+++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/firewall_provider.php
@@ -0,0 +1,24 @@
+loadFromExtension('security', array(
+ 'providers' => array(
+ 'default' => array(
+ 'memory' => $memory = array(
+ 'users' => array('foo' => array('password' => 'foo', 'roles' => 'ROLE_USER')),
+ ),
+ ),
+ 'with-dash' => array(
+ 'memory' => $memory,
+ ),
+ ),
+ 'firewalls' => array(
+ 'main' => array(
+ 'provider' => 'default',
+ 'form_login' => true,
+ ),
+ 'other' => array(
+ 'provider' => 'with-dash',
+ 'form_login' => true,
+ ),
+ ),
+));
diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/listener_provider.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/listener_provider.php
new file mode 100644
index 0000000000000..d7f1cd6973f36
--- /dev/null
+++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/listener_provider.php
@@ -0,0 +1,16 @@
+loadFromExtension('security', array(
+ 'providers' => array(
+ 'default' => array(
+ 'memory' => array(
+ 'users' => array('foo' => array('password' => 'foo', 'roles' => 'ROLE_USER')),
+ ),
+ ),
+ ),
+ 'firewalls' => array(
+ 'main' => array(
+ 'form_login' => array('provider' => 'default'),
+ ),
+ ),
+));
diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/firewall_provider.xml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/firewall_provider.xml
new file mode 100644
index 0000000000000..bd87fee4abae9
--- /dev/null
+++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/firewall_provider.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/listener_provider.xml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/listener_provider.xml
new file mode 100644
index 0000000000000..b1bcd8eae8155
--- /dev/null
+++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/listener_provider.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/firewall_provider.yml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/firewall_provider.yml
new file mode 100644
index 0000000000000..11c329aa8e2fe
--- /dev/null
+++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/firewall_provider.yml
@@ -0,0 +1,16 @@
+security:
+ providers:
+ default:
+ memory:
+ users: { foo: { password: foo, roles: ROLE_USER } }
+ with-dash:
+ memory:
+ users: { foo: { password: foo, roles: ROLE_USER } }
+
+ firewalls:
+ main:
+ provider: default
+ form_login: true
+ other:
+ provider: with-dash
+ form_login: true
diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/listener_provider.yml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/listener_provider.yml
new file mode 100644
index 0000000000000..652f23b5f0425
--- /dev/null
+++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/listener_provider.yml
@@ -0,0 +1,10 @@
+security:
+ providers:
+ default:
+ memory:
+ users: { foo: { password: foo, roles: ROLE_USER } }
+
+ firewalls:
+ main:
+ form_login:
+ provider: default