10000 Merge branch '6.0' into 6.1 · symfony/symfony-docs@70180d5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 70180d5

Browse files
committed
Merge branch '6.0' into 6.1
* 6.0: Update Doc of csrf_protection configuration in framework level
2 parents 0cffbc5 + 01f301b commit 70180d5

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

537+
.. configuration-block::
538+
539+
.. code-block:: yaml
540+
541+
# config/packages/framework.yaml
542+
framework:
543+
# ...
544+
csrf_protection: true
545+
546+
.. code-block:: xml
547+
548+
<!-- config/packages/framework.xml -->
549+
<?xml version="1.0" encoding="UTF-8" ?>
550+
<container xmlns="http://symfony.com/schema/dic/services"
551+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
552+
xmlns:framework="http://symfony.com/schema/dic/symfony"
553+
xsi:schemaLocation="http://symfony.com/schema/dic/services
554+
https://symfony.com/schema/dic/services/services-1.0.xsd
555+
http://symfony.com/schema/dic/symfony
556+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
557+
<framework:config>
558+
<framework:csrf-protection enabled="true"/>
559+
</framework:config>
560+
</container>
561+
562+
.. code-block:: php
563+
564+
// config/packages/framework.php
565+
use Symfony\Config\FrameworkConfig;
566+
return static function (FrameworkConfig $framework) {
567+
$framework->csrfProtection()
568+
->enabled(true)
569+
;
570+
};
571+
537572
If you're using forms, but want to avoid starting your session (e.g. using
538573
forms in an API-only website), ``csrf_protection`` will need to be set to
539574
``false``.

0 commit comments

Comments
 (0)
0