Skip to content

The security component must be installed to use csrf_token() #8821

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions security/csrf_in_login_form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ for CSRF. In this article you'll learn how you can use it in your login form.
Configuring CSRF Protection
---------------------------

First, make sure that the CSRF protection is enabled in the main configuration
file:
First, install the Security component in your project:

.. code-block:: terminal

$ composer require security
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-csrf is enough

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, you need the Form component for the Twig function to be available.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, it should be composer require security-csrf form, correct?


Then, enable the CSRF protection in the framework configuration file:

.. configuration-block::

Expand Down Expand Up @@ -52,8 +57,8 @@ file:
'csrf_protection' => null,
));

Then, the security component needs a CSRF token provider. You can set this to
use the default provider available in the security component:
The security component needs a CSRF token provider. You can set this to use the
default provider available in the security component:

.. configuration-block::

Expand Down