From d697abb793e12e0dd4e466ba6cf16f2d74852975 Mon Sep 17 00:00:00 2001 From: Chris Wilkinson Date: Tue, 29 Aug 2017 09:36:35 +0100 Subject: [PATCH] Stop delete_cookies keys from being normalized --- .../DependencyInjection/MainConfiguration.php | 1 + .../Tests/DependencyInjection/CompleteConfigurationTest.php | 6 ++++++ .../Tests/DependencyInjection/Fixtures/php/container1.php | 4 +++- .../Tests/DependencyInjection/Fixtures/xml/container1.xml | 6 +++++- .../Tests/DependencyInjection/Fixtures/yml/container1.yml | 4 +++- 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php index df6380224cd20..8b034fc9b6582 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php @@ -264,6 +264,7 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto ->fixXmlConfig('delete_cookie') ->children() ->arrayNode('delete_cookies') + ->normalizeKeys(false) ->beforeNormalization() ->ifTrue(function ($v) { return is_array($v) && is_int(key($v)); }) ->then(function ($v) { return array_map(function ($v) { return array('name' => $v); }, $v); }) diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php index d273fb05942b3..c418099d03de3 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php @@ -238,6 +238,12 @@ public function testRememberMeThrowExceptions() $this->assertFalse($service->getArgument(5)); } + public function testCookieClearingName() + { + $container = $this->getContainer('container1'); + $this->assertArrayHasKey('cookie-name', $container->getDefinition('security.logout.handler.cookie_clearing.secure')->getArgument(0)); + } + protected function getContainer($file) { $file = $file.'.'.$this->getFileExtension(); 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 b16a46ff03457..a687da8a5080f 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/container1.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/container1.php @@ -70,7 +70,9 @@ 'switch_user' => true, 'x509' => true, 'remote_user' => true, - 'logout' => true, + 'logout' => array( + 'delete_cookies' => array('cookie-name' => true), + ), 'remember_me' => array('key' => 'TheKey'), ), 'host' => 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 1a56aa88fda07..2452b194f39e9 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/container1.xml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/container1.xml @@ -55,7 +55,11 @@ - + + + + + diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/container1.yml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/container1.yml index 93c231ea235f1..ea0f3ef52e49c 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/container1.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/container1.yml @@ -53,7 +53,9 @@ security: switch_user: true x509: true remote_user: true - logout: true + logout: + delete_cookies: + cookie-name: ~ remember_me: key: TheKey host: