Skip to content

Commit 33bf1ac

Browse files
committed
[#8003] add XML and PHP config examples
1 parent 4da5615 commit 33bf1ac

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

security/csrf_in_login_form.rst

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,38 @@ Configuring CSRF Protection
1919
First, make sure that the CSRF protection is enabled in the main cofiguration
2020
file:
2121

22-
.. code-block:: yaml
22+
.. configuration-block::
23+
24+
.. code-block:: yaml
25+
26+
# app/config/config.yml
27+
framework:
28+
# ...
29+
csrf_protection: ~
30+
31+
.. code-block:: xml
2332
24-
# app/config/config.yml
25-
framework:
26-
# ...
27-
csrf_protection: ~
33+
<!-- app/config/config.xml -->
34+
<?xml version="1.0" encoding="UTF-8" ?>
35+
<container xmlns="http://symfony.com/schema/dic/services"
36+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
37+
xmlns:framework="http://symfony.com/schema/dic/symfony"
38+
xsi:schemaLocation="http://symfony.com/schema/dic/services
39+
http://symfony.com/schema/dic/services/services-1.0.xsd
40+
http://symfony.com/schema/dic/symfony
41+
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
42+
43+
<framework:config>
44+
<framework:csrf-protection enabled="true" />
45+
</framework:config>
46+
</container>
47+
48+
.. code-block:: php
49+
50+
// app/config/config.php
51+
$container->loadFromExtension('framework', array(
52+
'csrf_protection' => null,
53+
));
2854
2955
Then, the security component needs a CSRF token provider. You can set this to
3056
use the default provider available in the security component:

0 commit comments

Comments
 (0)