From 6d23c8c41cb4bdc002e5501bc65e3c34f51780e8 Mon Sep 17 00:00:00 2001 From: Antanas Arvasevicius Date: Wed, 1 Mar 2017 14:16:35 +0200 Subject: [PATCH] #21809 [SecurityBundle] bugfix: if security provider's name contains upper cases then container didn't compile --- .../DependencyInjection/SecurityExtension.php | 6 ++-- .../app/CamelCasedProviders/bundles.php | 16 ++++++++++ .../app/CamelCasedProviders/config.yml | 30 +++++++++++++++++++ ...amelCasedProvidersCausesExceptionsTest.php | 20 +++++++++++++ 4 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CamelCasedProviders/bundles.php create mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CamelCasedProviders/config.yml create mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CamelCasedProvidersCausesExceptionsTest.php diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php index 36c16e0dbc..2fd12c9436 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php @@ -509,7 +509,7 @@ class SecurityExtension extends Extension // Parses a tag and returns the id for the related user provider service private function createUserDaoProvider($name, $provider, ContainerBuilder $container) { - $name = $this->getUserProviderId(strtolower($name)); + $name = $this->getUserProviderId($name); // Doctrine Entity and In-memory DAO provider are managed by factories foreach ($this->userProviderFactories as $factory) { @@ -533,7 +533,7 @@ class SecurityExtension extends Extension if (isset($provider['chain'])) { $providers = array(); foreach ($provider['chain']['providers'] as $providerName) { - $providers[] = new Reference($this->getUserProviderId(strtolower($providerName))); + $providers[] = new Reference($this->getUserProviderId($providerName)); } $container @@ -548,7 +548,7 @@ class SecurityExtension extends Extension private function getUserProviderId($name) { - return 'security.user.provider.concrete.'.$name; + return 'security.user.provider.concrete.'.strtolower($name); } private function createExceptionListener($container, $config, $id, $defaultEntryPoint, $stateless) diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CamelCasedProviders/bundles.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CamelCasedProviders/bundles.php new file mode 100644 index 0000000000..86614bdb89 --- /dev/null +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CamelCasedProviders/bundles.php @@ -0,0 +1,16 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +return array( + new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), + new Symfony\Bundle\SecurityBundle\SecurityBundle(), + new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), +); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CamelCasedProviders/config.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CamelCasedProviders/config.yml new file mode 100644 index 0000000000..0b21534ecf --- /dev/null +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CamelCasedProviders/config.yml @@ -0,0 +1,30 @@ +imports: + - { resource: ./../config/framework.yml } + +doctrine: + dbal: + driver: pdo_sqlite + memory: true + charset: UTF8 + + orm: + entity_managers: + default: + + auto_mapping: true + +security: + providers: + camelCasedName: + entity: + class: Symfony\Component\Security\Core\User\User + + firewalls: + default: + anonymous: ~ + provider: camelCasedName + + encoders: + Symfony\Component\Security\Core\User\User: plaintext + + diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CamelCasedProvidersCausesExceptionsTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CamelCasedProvidersCausesExceptionsTest.php new file mode 100644 index 0000000000..41db3338da --- /dev/null +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/CamelCasedProvidersCausesExceptionsTest.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\SecurityBundle\Tests\Functional; + +class CamelCasedProvidersCausesExceptionsTest extends WebTestCase +{ + public function testBugfixExceptionThenCamelCasedProviderIsGiven() + { + $client = $this->createClient(array('test_case' => 'CamelCasedProviders', 'root_config' => 'config.yml')); + } +}