Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 01f301b

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: Update Doc of csrf_protection configuration in framework level
2 parents e5ea3c5 + c3b1ff5 commit 01f301b

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
@@ -563,6 +563,41 @@ enabled
563563
This option can be used to disable CSRF protection on *all* forms. But you
564564
can also :ref:`disable CSRF protection on individual forms <form-csrf-customization>`.
565565

566+
.. configuration-block::
567+
568+
.. code-block:: yaml
569+
570+
# config/packages/framework.yaml
571+
framework:
572+
# ...
573+
csrf_protection: true
574+
575+
.. code-block:: xml
576+
577+
<!-- config/packages/framework.xml -->
578+
<?xml version="1.0" encoding="UTF-8" ?>
579+
<container xmlns="http://symfony.com/schema/dic/services"
580+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
581+
xmlns:framework="http://symfony.com/schema/dic/symfony"
582+
xsi:schemaLocation="http://symfony.com/schema/dic/services
583+
https://symfony.com/schema/dic/services/services-1.0.xsd
584+
http://symfony.com/schema/dic/symfony
585+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
586+
<framework:config>
587+
<framework:csrf-protection enabled="true"/>
588+
</framework:config>
589+
</container>
590+
591+
.. code-block:: php
592+
593+
// config/packages/framework.php
594+
use Symfony\Config\FrameworkConfig;
595+
return static function (FrameworkConfig $framework) {
596+
$framework->csrfProtection()
597+
->enabled(true)
598+
;
599+
};
600+
566601
If you're using forms, but want to avoid starting your session (e.g. using
567602
forms in an API-only website), ``csrf_protection`` will need to be set to
568603
``false``.

0 commit comments

Comments
 (0)