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 @@ -593,6 +593,41 @@ enabled
593
593
This option can be used to disable CSRF protection on *all * forms. But you
594
594
can also :ref: `disable CSRF protection on individual forms <form-csrf-customization >`.
595
595
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
+
596
631
If you're using forms, but want to avoid starting your session (e.g. using
597
632
forms in an API-only website), ``csrf_protection `` will need to be set to
598
633
``false ``.
You can’t perform that action at this time.
0 commit comments