@@ -16,17 +16,27 @@ the session lasts using a cookie with the ``remember_me`` firewall option:
16
16
17
17
# app/config/security.yml
18
18
firewalls :
19
- main :
19
+ default :
20
+ # ...
20
21
remember_me :
21
22
key : " %secret%"
22
23
lifetime : 604800 # 1 week in seconds
23
24
path : /
25
+ # by default, the feature is enabled by checking a
26
+ # checkbox in the login form (see below), uncomment the
27
+ # below lines to always enable it.
28
+ # always_remember_me: true
24
29
25
30
.. code-block :: xml
26
31
27
32
<!-- app/config/security.xml -->
28
33
<config >
29
- <firewall >
34
+ <firewall name =" default" >
35
+ <!-- ... -->
36
+
37
+ <!-- by default, the feature is enabled by checking a checkbox
38
+ in the login form (see below), add always-remember-me="true"
39
+ to always enable it. -->
30
40
<remember-me
31
41
key = " %secret%"
32
42
lifetime = " 604800" <!-- 1 week in seconds -->
@@ -40,11 +50,16 @@ the session lasts using a cookie with the ``remember_me`` firewall option:
40
50
// app/config/security.php
41
51
$container->loadFromExtension('security', array(
42
52
'firewalls' => array(
43
- 'main' => array(
53
+ 'default' => array(
54
+ // ...
44
55
'remember_me' => array(
45
56
'key' => '%secret%',
46
57
'lifetime' => 604800, // 1 week in seconds
47
58
'path' => '/',
59
+ // by default, the feature is enabled by checking a
60
+ // checkbox in the login form (see below), uncomment
61
+ // the below lines to always enable it.
62
+ //'always_remember_me' => true,
48
63
),
49
64
),
50
65
),
@@ -94,21 +109,30 @@ The ``remember_me`` firewall defines the following configuration options:
94
109
"Remember Me" feature is always enabled, regardless of the desire of the
95
110
end user.
96
111
112
+ ``token_provider `` (default value: ``null ``)
113
+ Defines the service id of a token provider to use. By default, tokens are
114
+ stored in a cookie. For example, you might want to store the token in a
115
+ database, to not have a (hashed) version of the password in a cookie. The
116
+ DoctrineBridge comes with a
117
+ ``Symfony\Bridge\Doctrine\Security\RememberMe\DoctrineTokenProvider `` that
118
+ you can use.
119
+
97
120
Forcing the User to Opt-Out of the Remember Me Feature
98
121
------------------------------------------------------
99
122
100
123
It's a good idea to provide the user with the option to use or not use the
101
124
remember me functionality, as it will not always be appropriate. The usual
102
125
way of doing this is to add a checkbox to the login form. By giving the checkbox
103
- the name ``_remember_me ``, the cookie will automatically be set when the checkbox
104
- is checked and the user successfully logs in. So, your specific login form
105
- might ultimately look like this:
126
+ the name ``_remember_me `` (or the name you configured using ``remember_me_parameter ``),
127
+ the cookie will automatically be set when the checkbox is checked and the user
128
+ successfully logs in. So, your specific login form might ultimately look like
129
+ this:
106
130
107
131
.. configuration-block ::
108
132
109
133
.. code-block :: html+jinja
110
134
111
- {# src/Acme/SecurityBundle/ Resources/views/Security /login.html.twig #}
135
+ {# app/ Resources/views/security /login.html.twig #}
112
136
{% if error %}
113
137
<div>{{ error.message }}</div>
114
138
{% endif %}
@@ -128,7 +152,7 @@ might ultimately look like this:
128
152
129
153
.. code-block :: html+php
130
154
131
- <!-- src/Acme/SecurityBundle/ Resources/views/Security /login.html.php -->
155
+ <!-- app/ Resources/views/security /login.html.php -->
132
156
<?php if ($error): ?>
133
157
<div><?php echo $error->getMessage() ?></div>
134
158
<?php endif ?>
@@ -150,7 +174,7 @@ might ultimately look like this:
150
174
The user will then automatically be logged in on subsequent visits while
151
175
the cookie remains valid.
152
176
153
- Forcing the User to Re-authenticate before Accessing certain Resources
177
+ Forcing the User to Re-Authenticate before Accessing certain Resources
154
178
----------------------------------------------------------------------
155
179
156
180
When the user returns to your site, they are authenticated automatically based
0 commit comments