Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.3k
csrf_token now can be used without installing the Form component#9488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -12,12 +12,11 @@ CSRF protection works by adding a hidden field to your form that contains a | ||
| value that only you and your user know. This ensures that the user - not some | ||
| other entity - is submitting the given data. | ||
| Before using the CSRF protection, install it in your project: | ||
| .. code-block:: terminal | ||
| $ composer require security-csrf | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Do we now need to show how to install forms for the section where we integrate CSRF tokens into a Symfony form? Or is it too obvious that you do of course need the Form component for them? MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I agree with you that it would be too obvious to install | ||
| Then, enable/disable the CSRF protection with the ``csrf_protection`` option | ||
| (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. | ||
| CSRF Protection in HTML Forms | ||
| ----------------------------- | ||
| .. versionadded:: 4.1 | ||
| In Symfony versions prior to 4.1, CSRF support required installing the | ||
| Symfony Form component even if you didn't use it. | ||
| It's also possible to add CSRF protection to regular HTML forms not managed by | ||
| the Symfony Form component, for example the simple forms used to delete items. | ||
| First, use the ``csrf_token()`` function in the Twig template to generate a CSRF | ||