Skip to content

Commit 75c68f3

Browse files
committed
[Form] remove deprecated CSRF options
1 parent 380ce60 commit 75c68f3

File tree

5 files changed

+4
-107
lines changed

5 files changed

+4
-107
lines changed

src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -231,36 +231,6 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto
231231
->arrayNode('logout')
232232
->treatTrueLike(array())
233233
->canBeUnset()
234-
->beforeNormalization()
235-
->ifTrue(function ($v) { return isset($v['csrf_provider']) && isset($v['csrf_token_generator']); })
236-
->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'.")
237-
->end()
238-
->beforeNormalization()
239-
->ifTrue(function ($v) { return isset($v['intention']) && isset($v['csrf_token_id']); })
240-
->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'.")
241-
->end()
242-
->beforeNormalization()
243-
->ifTrue(function ($v) { return isset($v['csrf_provider']); })
244-
->then(function ($v) {
245-
@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);
246-
247-
$v['csrf_token_generator'] = $v['csrf_provider'];
248-
unset($v['csrf_provider']);
249-
250-
return $v;
251-
})
252-
->end()
253-
->beforeNormalization()
254-
->ifTrue(function ($v) { return isset($v['intention']); })
255-
->then(function ($v) {
256-
@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);
257-
258-
$v['csrf_token_id'] = $v['intention'];
259-
unset($v['intention']);
260-
261-
return $v;
262-
})
263-
->end()
264234
->children()
265235
->scalarNode('csrf_parameter')->defaultValue('_csrf_token')->end()
266236
->scalarNode('csrf_token_generator')->cannotBeEmpty()->end()

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/FormLoginFactory.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,6 @@ public function addConfiguration(NodeDefinition $node)
4848
parent::addConfiguration($node);
4949

5050
$node
51-
->beforeNormalization()
52-
->ifTrue(function ($v) { return isset($v['csrf_provider']) && isset($v['csrf_token_generator']); })
53-
->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'.")
54-
->end()
55-
->beforeNormalization()
56-
->ifTrue(function ($v) { return isset($v['csrf_provider']); })
57-
->then(function ($v) {
58-
@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);
59-
60-
$v['csrf_token_generator'] = $v['csrf_provider'];
61-
unset($v['csrf_provider']);
62-
63-
return $v;
64-
})
65-
->end()
6651
->children()
6752
->scalarNode('csrf_token_generator')->cannotBeEmpty()->end()
6853
->end()

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/MainConfigurationTest.php

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -91,54 +91,6 @@ public function testCsrfAliases()
9191
$this->assertEquals('a_token_id', $processedConfig['firewalls']['stub']['logout']['csrf_token_id']);
9292
}
9393

94-
/**
95-
* @group legacy
96-
*/
97-
public function testLegacyCsrfAliases()
98-
{
99-
$config = array(
100-
'firewalls' => array(
101-
'stub' => array(
102-
'logout' => array(
103-
'csrf_provider' => 'a_token_generator',
104-
'intention' => 'a_token_id',
105-
),
106-
),
107-
),
108-
);
109-
$config = array_merge(static::$minimalConfig, $config);
110-
111-
$processor = new Processor();
112-
$configuration = new MainConfiguration(array(), array());
113-
$processedConfig = $processor->processConfiguration($configuration, array($config));
114-
$this->assertTrue(isset($processedConfig['firewalls']['stub']['logout']['csrf_token_generator']));
115-
$this->assertEquals('a_token_generator', $processedConfig['firewalls']['stub']['logout']['csrf_token_generator']);
116-
$this->assertTrue(isset($processedConfig['firewalls']['stub']['logout']['csrf_token_id']));
117-
$this->assertEquals('a_token_id', $processedConfig['firewalls']['stub']['logout']['csrf_token_id']);
118-
}
119-
120-
/**
121-
* @expectedException \InvalidArgumentException
122-
*/
123-
public function testCsrfOriginalAndAliasValueCausesException()
124-
{
125-
$config = array(
126-
'firewalls' => array(
127-
'stub' => array(
128-
'logout' => array(
129-
'csrf_token_id' => 'a_token_id',
130-
'intention' => 'old_name',
131-
),
132-
),
133-
),
134-
);
135-
$config = array_merge(static::$minimalConfig, $config);
136-
137-
$processor = new Processor();
138-
$configuration = new MainConfiguration(array(), array());
139-
$processor->processConfiguration($configuration, array($config));
140-
}
141-
14294
public function testDefaultUserCheckers()
14395
{
14496
$processor = new Processor();

src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Form/UserLoginType.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ public function buildForm(FormBuilderInterface $builder, array $options)
7676
*/
7777
public function configureOptions(OptionsResolver $resolver)
7878
{
79-
/* Note: the form's intention must correspond to that for the form login
80-
* listener in order for the CSRF token to validate successfully.
79+
/* Note: the form's CSRF token ID must correspond to that for the form
80+
* login listener in order for the CSRF token to validate successfully.
8181
*/
8282

8383
$resolver->setDefaults(array(
84-
'intention' => 'authenticate',
84+
'csrf_token_id' => 'authenticate',
8585
));
8686
}
8787
}

src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,6 @@ public function finishView(FormView $view, FormInterface $form, array $options)
121121
*/
122122
public function configureOptions(OptionsResolver $resolver)
123123
{
124-
// BC clause for the "intention" option
125-
$csrfTokenId = function (Options $options) {
126-
if (null !== $options['intention']) {
127-
@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);
128-
}
129-
130-
return $options['intention'];
131-
};
132-
133124
// BC clause for the "csrf_provider" option
134125
$csrfTokenManager = function (Options $options) {
135126
if ($options['csrf_provider'] instanceof CsrfTokenManagerInterface) {
@@ -157,9 +148,8 @@ public function configureOptions(OptionsResolver $resolver)
157148
'csrf_field_name' => $this->defaultFieldName,
158149
'csrf_message' => 'The CSRF token is invalid. Please try to resubmit the form.',
159150
'csrf_token_manager' => $csrfTokenManager,
160-
'csrf_token_id' => $csrfTokenId,
151+
'csrf_token_id' => null,
161152
'csrf_provider' => null, // deprecated
162-
'intention' => null, // deprecated
163153
));
164154

165155
$resolver->setNormalizer('csrf_provider', $csrfProviderNormalizer);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy