@@ -39,8 +39,8 @@ First, enable form login under your firewall:
39
39
<!-- app/config/security.xml -->
40
40
<?xml version =" 1.0" encoding =" UTF-8" ?>
41
41
<srv : container xmlns =" http://symfony.com/schema/dic/security"
42
- xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
43
42
xmlns : srv =" http://symfony.com/schema/dic/services"
43
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
44
44
xsi : schemaLocation =" http://symfony.com/schema/dic/services
45
45
http://symfony.com/schema/dic/services/services-1.0.xsd" >
46
46
10000
@@ -82,7 +82,6 @@ bundle::
82
82
namespace AppBundle\Controller;
83
83
84
84
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
85
- use Symfony\Component\HttpFoundation\Request;
86
85
87
86
class SecurityController extends Controller
88
87
{
@@ -126,6 +125,7 @@ under your ``form_login`` configuration (``/login`` and ``/login_check``):
126
125
login_route :
127
126
path : /login
128
127
defaults : { _controller: AppBundle:Security:login }
128
+
129
129
login_check :
130
130
path : /login_check
131
131
# no controller is bound to this route
@@ -159,6 +159,7 @@ under your ``form_login`` configuration (``/login`` and ``/login_check``):
159
159
$collection->add('login_route', new Route('/login', array(
160
160
'_controller' => 'AppBundle:Security:login',
161
161
)));
162
+
162
163
$collection->add('login_check', new Route('/login_check', array()));
163
164
// no controller is bound to this route
164
165
// as it's handled by the Security system
@@ -320,12 +321,13 @@ see :doc:`/cookbook/security/form_login`.
320
321
321
322
.. _book-security-common-pitfalls :
322
323
323
- Avoid common Pitfalls
324
+ Avoid Common Pitfalls
324
325
---------------------
325
326
326
327
When setting up your login form, watch out for a few common pitfalls.
327
328
328
- **1. Create the correct routes **
329
+ 1. Create the Correct Routes
330
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
329
331
330
332
First, be sure that you've defined the ``/login `` and ``/login_check ``
331
333
routes correctly and that they correspond to the ``login_path `` and
@@ -334,7 +336,8 @@ redirected to a 404 page instead of the login page, or that submitting
334
336
the login form does nothing (you just see the login form over and over
335
337
again).
336
338
337
- **2. Be sure the login page isn't secure (redirect loop!) **
339
+ 2. Be Sure the Login Page Isn't Secure (Redirect Loop!)
340
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
338
341
339
342
Also, be sure that the login page is accessible by anonymous users. For example,
340
343
the following configuration - which requires the ``ROLE_ADMIN `` role for
@@ -450,15 +453,17 @@ for the login page:
450
453
),
451
454
),
452
455
453
- **3. Be sure /login_check is behind a firewall **
456
+ 3. Be Sure /login_check Is Behind a Firewall
457
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
454
458
455
459
Next, make sure that your ``check_path `` URL (e.g. ``/login_check ``) is behind
456
460
the firewall you're using for your form login (in this example, the single
457
461
firewall matches *all * URLs, including ``/login_check ``). If ``/login_check ``
458
462
doesn't match any firewall, you'll receive a ``Unable to find the controller
459
463
for path "/login_check" `` exception.
460
464
461
- **4. Multiple firewalls don't share security context **
465
+ 4. Multiple Firewalls Don't Share Security Context
466
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
462
467
463
468
If you're using multiple firewalls and you authenticate against one firewall,
464
469
you will *not * be authenticated against any other firewalls automatically.
@@ -467,7 +472,8 @@ to explicitly specify the same :ref:`reference-security-firewall-context`
467
472
for different firewalls. But usually for most applications, having one
468
473
main firewall is enough.
469
474
470
- **5. Routing error pages are not covered by firewalls **
475
+ 5. Routing Error Pages Are not Covered by Firewalls
476
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
471
477
472
478
As routing is done *before * security, 404 error pages are not covered by
473
479
any firewall. This means you can't check for security or even access the
0 commit comments