Skip to content

Updated csrf_in_login_form.rst to include new labels #5942

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 3 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
23 changes: 17 additions & 6 deletions cookbook/security/csrf_in_login_form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ for CSRF. In this article you'll learn how you can use it in your login form.
Login CSRF attacks are a bit less well-known. See `Forging Login Requests`_
if you're curious about more details.

.. note::

Since SF 2.8 ``intention`` has been depreciated, and removed in SF 3.0. It is now labeled as ``csrf_token_id``. ``csrf_provider`` was changed in SF 3.0 to ``csrf_token_generator``.

Configuring CSRF Protection
---------------------------

Expand All @@ -33,7 +37,9 @@ provider available in the Security component:
# ...
form_login:
# ...
csrf_provider: security.csrf.token_manager
# Use csrf_provider in SF <2.8
Copy link
Member

Choose a reason for hiding this comment

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

no need for such comment. this is why we have a versionned doc. Just put a versionadded section saying that the name has changed in 2.8

# csrf_provider: security.csrf.token_manager
csrf_token_generator: security.csrf.token_manager

.. code-block:: xml

Expand Down Expand Up @@ -66,7 +72,9 @@ provider available in the Security component:
// ...
'form_login' => array(
// ...
'csrf_provider' => 'security.csrf.token_manager',
// Use csrf_provider in SF <2.8
// 'csrf_provider' => 'security.csrf.token_manager',
'csrf_token_generator' => 'security.csrf.token_manager',
),
),
),
Expand Down Expand Up @@ -124,7 +132,7 @@ After this, you have protected your login form against CSRF attacks.
.. tip::

You can change the name of the field by setting ``csrf_parameter`` and change
the token ID by setting ``intention`` in your configuration:
the token ID by setting ``csrf_token_id`` ~~``intention``~~ in your configuration:

.. configuration-block::

Expand All @@ -140,7 +148,8 @@ After this, you have protected your login form against CSRF attacks.
form_login:
# ...
csrf_parameter: _csrf_security_token
intention: a_private_string
# intention: a_private_string
csrf_token_id: a_private_string

.. code-block:: xml

Expand All @@ -158,7 +167,8 @@ After this, you have protected your login form against CSRF attacks.
<firewall name="secured_area">
<!-- ... -->
<form-login csrf-parameter="_csrf_security_token"
intention="a_private_string"
<!-- intention="a_private_string" -->
csrf_token_id="a_private_string"
/>
</firewall>
</config>
Expand All @@ -176,7 +186,8 @@ After this, you have protected your login form against CSRF attacks.
'form_login' => array(
// ...
'csrf_parameter' => '_csrf_security_token',
'intention' => 'a_private_string',
'csrf_token_id' => 'a_private_string'
// 'intention' => 'a_private_string',
),
),
),
Expand Down