Skip to content

[Form] remove deprecated CSRF options #16723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -231,36 +231,6 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto
->arrayNode('logout')
->treatTrueLike(array())
->canBeUnset()
->beforeNormalization()
->ifTrue(function ($v) { return isset($v['csrf_provider']) && isset($v['csrf_token_generator']); })
->thenInvalid("You should define a value for only one of 'csrf_provider' and 'csrf_token_generator' on a security firewall. Use 'csrf_token_generator' as this replaces 'csrf_provider'.")
->end()
->beforeNormalization()
->ifTrue(function ($v) { return isset($v['intention']) && isset($v['csrf_token_id']); })
->thenInvalid("You should define a value for only one of 'intention' and 'csrf_token_id' on a security firewall. Use 'csrf_token_id' as this replaces 'intention'.")
->end()
->beforeNormalization()
->ifTrue(function ($v) { return isset($v['csrf_provider']); })
->then(function ($v) {
@trigger_error("Setting the 'csrf_provider' configuration key on a security firewall is deprecated since version 2.8 and will be removed in 3.0. Use the 'csrf_token_generator' configuration key instead.", E_USER_DEPRECATED);

$v['csrf_token_generator'] = $v['csrf_provider'];
unset($v['csrf_provider']);

return $v;
})
->end()
->beforeNormalization()
->ifTrue(function ($v) { return isset($v['intention']); })
->then(function ($v) {
@trigger_error("Setting the 'intention' configuration key on a security firewall is deprecated since version 2.8 and will be removed in 3.0. Use the 'csrf_token_id' key instead.", E_USER_DEPRECATED);

$v['csrf_token_id'] = $v['intention'];
unset($v['intention']);

return $v;
})
->end()
->children()
->scalarNode('csrf_parameter')->defaultValue('_csrf_token')->end()
->scalarNode('csrf_token_generator')->cannotBeEmpty()->end()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,6 @@ public function addConfiguration(NodeDefinition $node)
parent::addConfiguration($node);

$node
->beforeNormalization()
->ifTrue(function ($v) { return isset($v['csrf_provider']) && isset($v['csrf_token_generator']); })
->thenInvalid("You should define a value for only one of 'csrf_provider' and 'csrf_token_generator' on a security firewall. Use 'csrf_token_generator' as this replaces 'csrf_provider'.")
->end()
->beforeNormalization()
->ifTrue(function ($v) { return isset($v['csrf_provider']); })
->then(function ($v) {
@trigger_error("Setting the 'csrf_provider' configuration key on a security firewall is deprecated since version 2.8 and will be removed in 3.0. Use the 'csrf_token_generator' configuration key instead.", E_USER_DEPRECATED);

$v['csrf_token_generator'] = $v['csrf_provider'];
unset($v['csrf_provider']);

return $v;
})
->end()
->children()
->scalarNode('csrf_token_generator')->cannotBeEmpty()->end()
->end()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,12 @@ public function finishView(FormView $view, FormInterface $form, array $options)
*/
public function configureOptions(OptionsResolver $resolver)
{
// BC clause for the "intention" option
$csrfTokenId = function (Options $options) {
if (null !== $options['intention']) {
@trigger_error('The form option "intention" is deprecated since version 2.8 and will be removed in 3.0. Use "csrf_token_id" instead.', E_USER_DEPRECATED);
}

return $options['intention'];
};

$resolver->setDefaults(array(
'csrf_protection' => $this->defaultEnabled,
'csrf_field_name' => $this->defaultFieldName,
'csrf_message' => 'The CSRF token is invalid. Please try to resubmit the form.',
'csrf_token_manager' => $this->defaultTokenManager,
'csrf_token_id' => $csrfTokenId,
'intention' => null, // deprecated
'csrf_token_id' => null,
));
}

Expand Down