diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f498202..f826744a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,8 @@ CHANGELOG 2.8.0 ----- - * deprecated the `key` setting of `anonymous` and `remember_me` in favor of the - `secret` setting. + * deprecated the `key` setting of `anonymous`, `remember_me` and `http_digest` + in favor of the `secret` setting. 2.6.0 ----- diff --git a/DependencyInjection/Security/Factory/HttpDigestFactory.php b/DependencyInjection/Security/Factory/HttpDigestFactory.php index 691714fa..63875f83 100644 --- a/DependencyInjection/Security/Factory/HttpDigestFactory.php +++ b/DependencyInjection/Security/Factory/HttpDigestFactory.php @@ -58,10 +58,26 @@ public function getKey() public function addConfiguration(NodeDefinition $node) { $node + ->beforeNormalization() + ->ifTrue(function ($v) { return isset($v['key']); }) + ->then(function ($v) { + if (isset($v['secret'])) { + throw new \LogicException('Cannot set both key and secret options for http_digest, use only secret instead.'); + } + + @trigger_error('http_digest.key is deprecated since version 2.8 and will be removed in 3.0. Use http_digest.secret instead.', E_USER_DEPRECATED); + + $v['secret'] = $v['key']; + + unset($v['key']); + + return $v; + }) + ->end() ->children() ->scalarNode('provider')->end() ->scalarNode('realm')->defaultValue('Secured Area')->end() - ->scalarNode('key')->isRequired()->cannotBeEmpty()->end() + ->scalarNode('secret')->isRequired()->cannotBeEmpty()->end() ->end() ; } @@ -76,7 +92,7 @@ protected function createEntryPoint($container, $id, $config, $defaultEntryPoint $container ->setDefinition($entryPointId, new DefinitionDecorator('security.authentication.digest_entry_point')) ->addArgument($config['realm']) - ->addArgument($config['key']) + ->addArgument($config['secret']) ; return $entryPointId; diff --git a/Tests/DependencyInjection/Fixtures/php/container1.php b/Tests/DependencyInjection/Fixtures/php/container1.php index 4789a6d3..fc9b07c4 100644 --- a/Tests/DependencyInjection/Fixtures/php/container1.php +++ b/Tests/DependencyInjection/Fixtures/php/container1.php @@ -64,7 +64,7 @@ 'simple' => array('pattern' => '/login', 'security' => false), 'secure' => array('stateless' => true, 'http_basic' => true, - 'http_digest' => array('key' => 'TheKey'), + 'http_digest' => array('secret' => 'TheSecret'), 'form_login' => true, 'anonymous' => true, 'switch_user' => true, diff --git a/Tests/DependencyInjection/Fixtures/xml/container1.xml b/Tests/DependencyInjection/Fixtures/xml/container1.xml index 61873a9f..19167551 100644 --- a/Tests/DependencyInjection/Fixtures/xml/container1.xml +++ b/Tests/DependencyInjection/Fixtures/xml/container1.xml @@ -49,7 +49,7 @@ - + diff --git a/Tests/DependencyInjection/Fixtures/yml/container1.yml b/Tests/DependencyInjection/Fixtures/yml/container1.yml index e14e7931..e8ed61ef 100644 --- a/Tests/DependencyInjection/Fixtures/yml/container1.yml +++ b/Tests/DependencyInjection/Fixtures/yml/container1.yml @@ -47,7 +47,7 @@ security: stateless: true http_basic: true http_digest: - key: TheKey + secret: TheSecret form_login: true anonymous: true switch_user: true