Skip to content

Commit c3b1ff5

Browse files
committed
Merge branch '4.4' into 5.4
* 4.4: Update Doc of csrf_protection configuration in framework level
2 parents 79358c0 + d96fcfe commit c3b1ff5

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

reference/configuration/framework.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,41 @@ enabled
593593
This option can be used to disable CSRF protection on *all* forms. But you
594594
can also :ref:`disable CSRF protection on individual forms <form-csrf-customization>`.
595595

596+
.. configuration-block::
597+
598+
.. code-block:: yaml
599+
600+
# config/packages/framework.yaml
601+
framework:
602+
# ...
603+
csrf_protection: true
604+
605+
.. code-block:: xml
606+
607+
<!-- config/packages/framework.xml -->
608+
<?xml version="1.0" encoding="UTF-8" ?>
609+
<container xmlns="http://symfony.com/schema/dic/services"
610+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
611+
xmlns:framework="http://symfony.com/schema/dic/symfony"
612+
xsi:schemaLocation="http://symfony.com/schema/dic/services
613+
https://symfony.com/schema/dic/services/services-1.0.xsd
614+
http://symfony.com/schema/dic/symfony
615+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
616+
<framework:config>
617+
<framework:csrf-protection enabled="true"/>
618+
</framework:config>
619+
</container>
620+
621+
.. code-block:: php
622+
623+
// config/packages/framework.php
624+
use Symfony\Config\FrameworkConfig;
625+
return static function (FrameworkConfig $framework) {
626+
$framework->csrfProtection()
627+
->enabled(true)
628+
;
629+
};
630+
596631
If you're using forms, but want to avoid starting your session (e.g. using
597632
forms in an API-only website), ``csrf_protection`` will need to be set to
598633
``false``.

0 commit comments

Comments
 (0)