@@ -8,10 +8,15 @@ When using a login form, you should make sure that you are protected against CSR
8
8
(`Cross-site request forgery `_). The Security component already has built-in support
9
9
for CSRF. In this article you'll learn how you can use it in your login form.
10
10
11
+ .. note ::
12
+
13
+ Login CSRF attacks are a bit less well-known. See `Forging Login Requests `_
14
+ if you're curious about more details.
15
+
11
16
Configuring CSRF
12
17
----------------
13
18
14
- At first, you have to configure the Security component so it can use CSRF protection.
19
+ First, configure the Security component so it can use CSRF protection.
15
20
The Security component needs a CSRF provider. You can set this to use the default
16
21
provider available in the Form component:
17
22
@@ -61,17 +66,18 @@ provider available in the Form component:
61
66
)
62
67
));
63
68
64
- The Security component can be configured further, but this is all information it needs
65
- to be able to use CSRF in the login form.
69
+ The Security component can be configured further, but this is all information
70
+ it needs to be able to use CSRF in the login form.
66
71
67
72
Rendering the CSRF field
68
73
------------------------
69
74
70
- Now the Security component checks for CSRF tokens, you have to add a *hidden * field
71
- to the login form containing the CSRF token. By default, this field is named as
72
- ``_csrf_token ``. That hidden field has to contain the CSRF token, which can be generated
73
- by using the ``csrf_token `` function. That function requires a token ID, which must
74
- be set to ``authenticate `` when using the login form:
75
+ Now that Security component will check for the CSRF token, you have to add
76
+ a *hidden * field to the login form containing the CSRF token. By default,
77
+ this field is named ``_csrf_token ``. That hidden field must contain the CSRF
78
+ token, which can be generated by using the ``csrf_token `` function. That
79
+ function requires a token ID, which must be set to ``authenticate `` when
80
+ using the login form:
75
81
76
82
.. configuration-block ::
77
83
@@ -162,3 +168,4 @@ After this, you have protected your login form against CSRF attacks.
162
168
));
163
169
164
170
.. _`Cross-site request forgery` : http://en.wikipedia.org/wiki/Cross-site_request_forgery
171
+ .. _`Forging Login Requests` : http://en.wikipedia.org/wiki/Cross-site_request_forgery#Forging_login_requests
0 commit comments