Skip to content

Commit 2160a0d

Browse files
committed
minor #16344 Update Doc of csrf_protection configuration in framework level (arcanisgk)
This PR was submitted for the 6.0 branch but it was squashed and merged into the 4.4 branch instead. Discussion ---------- Update Doc of csrf_protection configuration in framework level Update Doc of csrf_protection configuration in framework level, this configuration requires an example to clarify its implementation Commits ------- 9e59e57 Update Doc of csrf_protection configuration in framework level
2 parents 8b8492f + 9e59e57 commit 2160a0d

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

reference/configuration/framework.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,43 @@ If you're using forms, but want to avoid starting your session (e.g. using
358358
forms in an API-only website), ``csrf_protection`` will need to be set to
359359
``false``.
360360

361+
example:
362+
363+
.. configuration-block::
364+
365+
.. code-block:: yaml
366+
367+
# config/packages/framework.yaml
368+
framework:
369+
# ...
370+
csrf_protection: true #can be true or false
371+
372+
.. code-block:: xml
373+
374+
<!-- config/packages/framework.xml -->
375+
<?xml version="1.0" encoding="UTF-8" ?>
376+
<container xmlns="http://symfony.com/schema/dic/services"
377+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
378+
xmlns:framework="http://symfony.com/schema/dic/symfony"
379+
xsi:schemaLocation="http://symfony.com/schema/dic/services
380+
https://symfony.com/schema/dic/services/services-1.0.xsd
381+
http://symfony.com/schema/dic/symfony
382+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
383+
<framework:config>
384+
<framework:csrf-protection enabled="true"/>
385+
</framework:config>
386+
</container>
387+
388+
.. code-block:: php
389+
390+
// config/packages/framework.php
391+
use Symfony\Config\FrameworkConfig;
392+
return static function (FrameworkConfig $framework) {
393+
$framework->csrfProtection()
394+
->enabled(true) #can be true or false
395+
;
396+
};
397+
361398
.. _config-framework-error_controller:
362399

363400
error_controller

0 commit comments

Comments
 (0)