File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -563,6 +563,41 @@ enabled
563
563
This option can be used to disable CSRF protection on *all * forms. But you
564
564
can also :ref: `disable CSRF protection on individual forms <form-csrf-customization >`.
565
565
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
+
566
601
If you're using forms, but want to avoid starting your session (e.g. using
567
602
forms in an API-only website), ``csrf_protection `` will need to be set to
568
603
``false ``.
You can’t perform that action at this time.
0 commit comments