@@ -40,11 +40,11 @@ and your generated code may be slightly different:
40
40
.. versionadded :: 1.8
41
41
Support for login form authentication was added to ``make:auth `` in MakerBundle 1.8.
42
42
43
- This generates three things: ( 1) a login route & controller, ( 2) a template that
44
- renders the login form and ( 3) a :doc: `Guard authenticator </security/guard_authentication >`
45
- class that processes the login submit.
43
+ This generates the following: 1) a login route & controller, 2) a template that
44
+ renders the login form, 3) a :doc: `Guard authenticator </security/guard_authentication >`
45
+ class that processes the login submit and 4) updates the main security config file .
46
46
47
- The ``/login `` route & controller::
47
+ ** Step 1. ** The ``/login `` route & controller::
48
48
49
49
// src/Controller/SecurityController.php
50
50
namespace App\Controller;
@@ -73,8 +73,8 @@ The ``/login`` route & controller::
73
73
}
74
74
}
75
75
76
- The template has very little to do with security: it just generates a traditional
77
- HTML form that submits to ``/login ``:
76
+ ** Step 2. ** The template has very little to do with security: it just generates
77
+ a traditional HTML form that submits to ``/login ``:
78
78
79
79
.. code-block :: twig
80
80
@@ -115,7 +115,7 @@ HTML form that submits to ``/login``:
115
115
</form>
116
116
{% endblock %}
117
117
118
- The Guard authenticator processes the form submit::
118
+ ** Step 3. ** The Guard authenticator processes the form submit::
119
119
120
120
// src/Security/LoginFormAuthenticator.php
121
121
namespace App\Security;
@@ -212,6 +212,63 @@ The Guard authenticator processes the form submit::
212
212
}
213
213
}
214
214
215
+ **Step 4. ** Updates the main security config file to enable the Guard authenticator:
216
+
217
+ .. configuration-block ::
218
+
219
+ .. code-block :: yaml
220
+
221
+ # config/packages/security.yaml
222
+ security :
223
+ # ...
224
+
225
+ firewalls :
226
+ main :
227
+ # ...
228
+ guard :
229
+ authenticators :
230
+ - App\Security\LoginFormAuthenticator
231
+
232
+ .. code-block :: xml
233
+
234
+ <!-- config/packages/security.xml -->
235
+ <?xml version =" 1.0" charset =" UTF-8" ?>
236
+ <srv : container xmlns =" http://symfony.com/schema/dic/security"
237
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
238
+ xmlns : srv =" http://symfony.com/schema/dic/services"
239
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
240
+ http://symfony.com/schema/dic/services/services-1.0.xsd" >
241
+
242
+ <config >
243
+ <!-- ... -->
244
+ <firewall name =" main" >
245
+ <!-- ... -->
246
+ <guard >
247
+ <authenticator class =" App\Security\LoginFormAuthenticator" />
248
+ </guard >
249
+ </firewall >
250
+ </config >
251
+ </srv : container >
252
+
253
+ .. code-block :: php
254
+
255
+ // app/config/security.php
256
+ use App\Security\LoginFormAuthenticator;
257
+
258
+ $container->loadFromExtension('security', [
259
+ // ...
260
+ 'firewalls' => [
261
+ 'main' => [
262
+ // ...,
263
+ 'guard' => [
264
+ 'authenticators' => [
265
+ LoginFormAuthenticator::class,
266
+ ]
267
+ ],
268
+ ],
269
+ ],
270
+ ]);
271
+
215
272
Finishing the Login Form
216
273
------------------------
217
274
0 commit comments