Skip to content

Commit 1259323

Browse files
committed
minor #9488 csrf_token now can be used without installing the Form component (javiereguiluz)
This PR was squashed before being merged into the master branch (closes #9488). Discussion ---------- csrf_token now can be used without installing the Form component This fixes #9488. @xabbuh in your original code (https://github.com/symfony/symfony/pull/25197/files) the function was added to Twig Bridge so ... could you please verify if installing just `security-csrf` is enough to use this function or if we need to install some other package? Thanks! Commits ------- 3c48a0a csrf_token now can be used without installing the Form component
2 parents b73fda4 + 3c48a0a commit 1259323

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

security/csrf.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ CSRF protection works by adding a hidden field to your form that contains a
1212
value that only you and your user know. This ensures that the user - not some
1313
other entity - is submitting the given data.
1414

15-
Before using the CSRF protection, install it in your project (which in turn
16-
requires installing the Symfony Form component):
15+
Before using the CSRF protection, install it in your project:
1716

1817
.. code-block:: terminal
1918
20-
$ composer require security-csrf form
19+
$ composer require security-csrf
2120
2221
Then, enable/disable the CSRF protection with the ``csrf_protection`` option
2322
(see the :ref:`CSRF configuration reference <reference-framework-csrf-protection>`
@@ -278,6 +277,10 @@ After this, you have protected your login form against CSRF attacks.
278277
CSRF Protection in HTML Forms
279278
-----------------------------
280279

280+
.. versionadded:: 4.1
281+
In Symfony versions prior to 4.1, CSRF support required installing the
282+
Symfony Form component even if you didn't use it.
283+
281284
It's also possible to add CSRF protection to regular HTML forms not managed by
282285
the Symfony Form component, for example the simple forms used to delete items.
283286
First, use the ``csrf_token()`` function in the Twig template to generate a CSRF

0 commit comments

Comments
 (0)