diff --git a/DependencyInjection/Security/Factory/RememberMeFactory.php b/DependencyInjection/Security/Factory/RememberMeFactory.php index 884c7b57..27ec6ff9 100644 --- a/DependencyInjection/Security/Factory/RememberMeFactory.php +++ b/DependencyInjection/Security/Factory/RememberMeFactory.php @@ -108,7 +108,7 @@ public function createAuthenticator(ContainerBuilder $container, string $firewal $container ->setDefinition($authenticatorId, new ChildDefinition('security.authenticator.remember_me')) ->replaceArgument(0, new Reference($rememberMeServicesId)) - ->replaceArgument(3, array_intersect_key($config, $this->options)) + ->replaceArgument(3, $container->getDefinition($rememberMeServicesId)->getArgument(3)) ; foreach ($container->findTaggedServiceIds('security.remember_me_aware') as $serviceId => $attributes) { @@ -201,7 +201,12 @@ private function createRememberMeServices(ContainerBuilder $container, string $i } // remember-me options - $rememberMeServices->replaceArgument(3, array_intersect_key($config, $this->options)); + $mergedOptions = array_intersect_key($config, $this->options); + if ('auto' === $mergedOptions['secure']) { + $mergedOptions['secure'] = null; + } + + $rememberMeServices->replaceArgument(3, $mergedOptions); if ($config['user_providers']) { $userProviders = []; diff --git a/Tests/Functional/RememberMeCookieTest.php b/Tests/Functional/RememberMeCookieTest.php new file mode 100644 index 00000000..6bfa1ed4 --- /dev/null +++ b/Tests/Functional/RememberMeCookieTest.php @@ -0,0 +1,33 @@ +createClient(['test_case' => 'RememberMeCookie', 'root_config' => 'config.yml']); + + $client->request('POST', '/login', [ + '_username' => 'test', + '_password' => 'test', + ], [], [ + 'HTTPS' => (int) $https, + ]); + + $cookies = $client->getResponse()->headers->getCookies(ResponseHeaderBag::COOKIES_ARRAY); + + $this->assertEquals($expectedSecureFlag, $cookies['']['/']['REMEMBERME']->isSecure()); + } + + public function getSessionRememberMeSecureCookieFlagAutoHttpsMap() + { + return [ + [true, true], + [false, false], + ]; + } +} diff --git a/Tests/Functional/app/RememberMeCookie/bundles.php b/Tests/Functional/app/RememberMeCookie/bundles.php new file mode 100644 index 00000000..8d4a0249 --- /dev/null +++ b/Tests/Functional/app/RememberMeCookie/bundles.php @@ -0,0 +1,9 @@ +