@@ -57,7 +57,7 @@ authentication (i.e. the old-school username/password box):
5757
5858 encoders :
5959 Symfony\Component\Security\Core\User\User : plaintext
60-
60+
6161 .. code-block :: xml
6262
6363 <!-- app/config/config.xml -->
@@ -83,10 +83,10 @@ authentication (i.e. the old-school username/password box):
8383
8484 <encoder class =" Symfony\Component\Security\Core\User\User" algorithm =" plaintext" />
8585 </config >
86- </srv : container >
86+ </srv : container >
8787
8888 .. code-block :: php
89-
89+
9090 // app/config/config.php
9191 $container->loadFromExtension('security', array(
9292 'firewalls' => array(
@@ -147,14 +147,14 @@ Firewalls (Authentication)
147147When a user makes a request to a URL that's protected by a firewall, the
148148security system is activated. The job of the firewall is to determine whether
149149or not the user needs to be authenticated, and if he does, to send a response
150- back to the user initiating the authentication process.
150+ back to the user initiating the authentication process.
151151
152152A firewall is activated when the URL of an incoming request matches the configured
153153firewall's regular expression ``pattern `` config value. In this example, the
154154``pattern `` (``^/ ``) will match *every * incoming request. The fact that the
155155firewall is activated does *not * mean, however, that the HTTP authentication
156156username and password box is displayed for every URL. For example, any user
157- can access ``/foo `` without being prompted to authenticate.
157+ can access ``/foo `` without being prompted to authenticate.
158158
159159.. image :: /images/book/security_anonymous_user_access.png
160160 :align: center
@@ -238,7 +238,7 @@ the request flow is always the same:
238238 But with HTTP authentication, the user submits its credentials directly
239239 to the original URL (e.g. ``/admin/foo ``) and then the page is returned
240240 to the user in that same request (i.e. no redirect).
241-
241+
242242 These types of idiosyncrasies shouldn't cause you any problems, but they're
243243 good to keep in mind.
244244
@@ -277,7 +277,7 @@ First, enable form login under your firewall:
277277 form_login :
278278 login_path : /login
279279 check_path : /login_check
280-
280+
281281 .. code-block :: xml
282282
283283 <!-- app/config/config.xml -->
@@ -292,10 +292,10 @@ First, enable form login under your firewall:
292292 <form-login login_path =" /login" check_path =" /login_check" />
293293 </firewall >
294294 </config >
295- </srv : container >
295+ </srv : container >
296296
297297 .. code-block :: php
298-
298+
299299 // app/config/config.php
300300 $container->loadFromExtension('security', array(
301301 'firewalls' => array(
@@ -315,19 +315,19 @@ First, enable form login under your firewall:
315315 If you don't need to customize your ``login_path `` or ``check_path ``
316316 values (the values used here are the default values), you can shorten
317317 your configuration:
318-
318+
319319 .. configuration-block ::
320-
320+
321321 .. code-block :: yaml
322-
322+
323323 form_login : ~
324-
324+
325325 .. code-block :: xml
326-
326+
327327 <form-login />
328-
328+
329329 .. code-block :: php
330-
330+
331331 'form_login' => array(),
332332
333333 Now, when the security system initiates the authentication process, it will
@@ -519,7 +519,7 @@ see :doc:`/cookbook/security/form_login`.
519519.. sidebar :: Avoid Common Pitfalls
520520
521521 When setting up your login form, watch out for a few common pitfalls.
522-
522+
523523 **1. Create the correct routes **
524524
525525 First, be sure that you've defined the ``/login `` and ``/login_check ``
@@ -582,7 +582,7 @@ see :doc:`/cookbook/security/form_login`.
582582 Also, if your firewall does *not * allow for anonymous users, you'll need
583583 to create a special firewall that allows anonymous users for the login
584584 page:
585-
585+
586586 .. configuration-block ::
587587
588588 .. code-block :: yaml
@@ -599,10 +599,10 @@ see :doc:`/cookbook/security/form_login`.
599599
600600 <firewall name =" login_firewall" pattern =" ^/login$" >
601601 <anonymous />
602- </firewall >
602+ </firewall >
603603 <firewall name =" secured_area" pattern =" ^/" >
604604 <login_form />
605- </firewall >
605+ </firewall >
606606
607607 .. code-block :: php
608608
@@ -618,7 +618,7 @@ see :doc:`/cookbook/security/form_login`.
618618 ),
619619
620620 **3. Be sure ``/login_check`` is behind a firewall **
621-
621+
622622 Next, make sure that your ``check_path `` URL (e.g. ``/login_check ``)
623623 is behind the firewall you're using for your form login (in this example,
624624 the single firewall matches *all * URLs, including ``/login_check ``). If
@@ -673,7 +673,7 @@ You can define as many URL patterns as you need - each is a regular expression.
673673 access_control :
674674 - { path: ^/admin/users, roles: ROLE_SUPER_ADMIN }
675675 - { path: ^/admin, roles: ROLE_ADMIN }
676-
676+
677677 .. code-block :: xml
678678
679679 <!-- app/config/config.xml -->
@@ -683,10 +683,10 @@ You can define as many URL patterns as you need - each is a regular expression.
683683 <rule path =" ^/admin/users" role =" ROLE_SUPER_ADMIN" />
684684 <rule path =" ^/admin" role =" ROLE_ADMIN" />
685685 </access-control >
686- </config >
686+ </config >
687687
688688 .. code-block :: php
689-
689+
690690 // app/config/config.php
691691 $container->loadFromExtension('security', array(
692692 // ...
@@ -829,7 +829,7 @@ In fact, you've seen this already in the example in this chapter.
829829 users :
830830 ryan : { password: ryanpass, roles: 'ROLE_USER' }
831831 admin : { password: kitten, roles: 'ROLE_ADMIN' }
832-
832+
833833 .. code-block :: xml
834834
835835 <!-- app/config/config.xml -->
@@ -842,7 +842,7 @@ In fact, you've seen this already in the example in this chapter.
842842 </config >
843843
844844 .. code-block :: php
845-
845+
846846 // app/config/config.php
847847 $container->loadFromExtension('security', array(
848848 // ...
@@ -869,9 +869,9 @@ by Symfony (:class:`Symfony\\Component\\Security\\Core\\User\\User`).
869869 If your username is completely numeric (e.g. ``77 ``) or contains a dash
870870 (e.g. ``user-name ``), you should use that alternative syntax when specifying
871871 users in YAML:
872-
872+
873873 .. code-block :: yaml
874-
874+
875875 users :
876876 - { name: 77, password: pass, roles: 'ROLE_USER' }
877877 - { name: user-name, password: pass, roles: 'ROLE_USER' }
@@ -913,7 +913,7 @@ be stored in the database.
913913 * @ORM\Column(type="string", length="255")
914914 */
915915 protected $username;
916-
916+
917917 // ...
918918 }
919919
@@ -1001,7 +1001,7 @@ do the following:
10011001 algorithm : sha1
10021002 iterations : 1
10031003 encode_as_base64 : false
1004-
1004+
10051005 .. code-block :: xml
10061006
10071007 <!-- app/config/config.xml -->
@@ -1016,7 +1016,7 @@ do the following:
10161016 </config >
10171017
10181018 .. code-block :: php
1019-
1019+
10201020 // app/config/config.php
10211021 $container->loadFromExtension('security', array(
10221022 // ...
@@ -1058,7 +1058,7 @@ configure the encoder for that user:
10581058
10591059 encoders :
10601060 Acme\UserBundle\Entity\User : sha512
1061-
1061+
10621062 .. code-block :: xml
10631063
10641064 <!-- app/config/config.xml -->
@@ -1069,7 +1069,7 @@ configure the encoder for that user:
10691069 </config >
10701070
10711071 .. code-block :: php
1072-
1072+
10731073 // app/config/config.php
10741074 $container->loadFromExtension('security', array(
10751075 // ...
@@ -1119,7 +1119,7 @@ look like:
11191119 Anonymous users are technically authenticated, meaning that the ``isAuthenticated() ``
11201120 method of an anonymous user object will return true. To check if your
11211121 user is actually authenticated, check for the ``IS_AUTHENTICATED_FULLY ``
1122- role.
1122+ role.
11231123
11241124Using Multiple User Providers
11251125~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1189,7 +1189,7 @@ the user from both the ``in_memory`` and ``user_db`` providers.
11891189 If you have no reasons to separate your ``in_memory `` users from your
11901190 ``user_db `` users, you can accomplish this even more easily by combining
11911191 the two sources into a single provider:
1192-
1192+
11931193 .. configuration-block ::
11941194
11951195 .. code-block :: yaml
@@ -1244,7 +1244,7 @@ the first provider is always used:
12441244 realm : " Secured Demo Area"
12451245 provider : in_memory
12461246 form_login : ~
1247-
1247+
12481248 .. code-block :: xml
12491249
12501250 <!-- app/config/config.xml -->
@@ -1257,7 +1257,7 @@ the first provider is always used:
12571257 </config >
12581258
12591259 .. code-block :: php
1260-
1260+
12611261 // app/config/config.php
12621262 $container->loadFromExtension('security', array(
12631263 'firewalls' => array(
@@ -1360,7 +1360,7 @@ the firewall can handle this automatically for you when you activate the
13601360 path : /logout
13611361 target : /
13621362 # ...
1363-
1363+
13641364 .. code-block :: xml
13651365
13661366 <!-- app/config/config.xml -->
@@ -1373,7 +1373,7 @@ the firewall can handle this automatically for you when you activate the
13731373 </config >
13741374
13751375 .. code-block :: php
1376-
1376+
13771377 // app/config/config.php
13781378 $container->loadFromExtension('security', array(
13791379 'firewalls' => array(
@@ -1395,15 +1395,15 @@ them, you can omit them entirely and shorten your configuration:
13951395.. configuration-block ::
13961396
13971397 .. code-block :: yaml
1398-
1398+
13991399 logout : ~
1400-
1400+
14011401 .. code-block :: xml
1402-
1402+
14031403 <logout />
1404-
1404+
14051405 .. code-block :: php
1406-
1406+
14071407 'logout' => array(),
14081408
14091409 Note that you will *not * need to implement a controller for the ``/logout ``
@@ -1456,13 +1456,13 @@ the built-in helper function:
14561456.. configuration-block ::
14571457
14581458 .. code-block :: html+jinja
1459-
1459+
14601460 {% if is_granted('ROLE_ADMIN') %}
14611461 <a href="...">Delete</a>
14621462 {% endif %}
14631463
14641464 .. code-block :: html+php
1465-
1465+
14661466 <?php if ($view['security']->isGranted('ROLE_ADMIN')): ?>
14671467 <a href="...">Delete</a>
14681468 <?php endif; ?>
@@ -1659,6 +1659,6 @@ Learn more from the Cookbook
16591659
16601660.. _`security component` : https://github.com/symfony/Security
16611661.. _`SecurityExtraBundle` : https://github.com/schmittjoh/SecurityExtraBundle
1662- .. _`FOSUserBundle` : https://github.com/FriendsOfSymfony/UserBundle
1662+ .. _`FOSUserBundle` : https://github.com/FriendsOfSymfony/FOSUserBundle
16631663.. _`implement the \S erializable interface` : http://php.net/manual/en/class.serializable.php
16641664.. _`functions-online.com` : http://www.functions-online.com/sha1.html
0 commit comments