@@ -21,7 +21,8 @@ sections:
21
21
#. Fetching the current User object.
22
22
23
23
These are followed by a number of small (but still captivating) sections,
24
- like :ref: `logging out <book-security-logging-out >` and :ref: `encoding user passwords <security-encoding-password >`.
24
+ like :ref: `logging out <book-security-logging-out >` and
25
+ :ref: `encoding user passwords <security-encoding-password >`.
25
26
26
27
.. _book-security-firewalls :
27
28
@@ -362,6 +363,11 @@ probably only need one. If you *do* have multiple, you can configure which
362
363
*one * provider to use for your firewall under its ``provider `` key (e.g.
363
364
``provider: in_memory ``).
364
365
366
+ .. seealso ::
367
+
368
+ See :doc: `/cookbook/security/multiple_user_providers ` for
369
+ all the details about multiple providers setup.
370
+
365
371
Try to login using username ``admin `` and password ``kitten ``. You should
366
372
see an error!
367
373
@@ -666,11 +672,11 @@ Add Code to Deny Access
666
672
667
673
There are **two ** ways to deny access to something:
668
674
669
- 1) :ref: `access_control in security.yml <security-authorization-access-control >`
675
+ #. :ref: `access_control in security.yml <security-authorization-access-control >`
670
676
allows you to protect URL patterns (e.g. ``/admin/* ``). This is easy,
671
677
but less flexible;
672
678
673
- 2) :ref: `in your code via the security.authorization_checker service <book-security-securing-controller >`.
679
+ #. :ref: `in your code via the security.authorization_checker service <book-security-securing-controller >`.
674
680
675
681
.. _security-authorization-access-control :
676
682
@@ -838,8 +844,10 @@ In both cases, a special
838
844
is thrown, which ultimately triggers a 403 HTTP response inside Symfony.
839
845
840
846
That's it! If the user isn't logged in yet, they will be asked to login (e.g.
841
- redirected to the login page). If they *are * logged in, they'll be shown
842
- the 403 access denied page (which you can :ref: `customize <cookbook-error-pages-by-status-code >`).
847
+ redirected to the login page). If they *are * logged in, but do *not * have the
848
+ ``ROLE_ADMIN `` role, they'll be shown the 403 access denied page (which you can
849
+ :ref: `customize <cookbook-error-pages-by-status-code >`). If they are logged in
850
+ and have the correct roles, the code will be executed.
843
851
844
852
.. _book-security-securing-controller-annotations :
845
853
@@ -881,14 +889,13 @@ the built-in helper function:
881
889
<a href="...">Delete</a>
882
890
<?php endif ?>
883
891
884
- If you use this function and are *not * behind a firewall, an exception
885
- will be thrown. Again, it's almost always a good
886
- idea to have a main firewall that covers all URLs (as has been shown
887
- in this chapter).
892
+ If you use this function and you are *not * behind a firewall, an exception will
893
+ be thrown. Again, it's almost always a good idea to have a main firewall that
894
+ covers all URLs (as shown before in this chapter).
888
895
889
896
.. caution ::
890
897
891
- Be careful with this in your layout or on your error pages! Because of
898
+ Be careful with this in your base layout or on your error pages! Because of
892
899
some internal Symfony details, to avoid broken error pages in the ``prod ``
893
900
environment, wrap calls in these templates with a check for ``app.user ``:
894
901
@@ -899,10 +906,10 @@ in this chapter).
899
906
Securing other Services
900
907
.......................
901
908
902
- In fact, anything in Symfony can be protected by doing something similar
903
- to this . For example, suppose you have a service (i.e. a PHP class) whose
904
- job is to send emails. You can restrict use of this class - no matter where
905
- it's being used from - to only certain users.
909
+ Anything in Symfony can be protected by doing something similar to the code
910
+ used to secure a controller . For example, suppose you have a service (i.e. a
911
+ PHP class) whose job is to send emails. You can restrict use of this class - no
912
+ matter where it's being used from - to only certain users.
906
913
907
914
For more information see :doc: `/cookbook/security/securing_services `.
908
915
@@ -911,7 +918,8 @@ Checking to see if a User is Logged In (IS_AUTHENTICATED_FULLY)
911
918
912
919
So far, you've checked access based on roles - those strings that start with
913
920
``ROLE_ `` and are assigned to users. But if you *only * want to check if a
914
- user is logged in (you don't care about roles), then you can see ``IS_AUTHENTICATED_FULLY ``::
921
+ user is logged in (you don't care about roles), then you can use
922
+ ``IS_AUTHENTICATED_FULLY ``::
915
923
916
924
// ...
917
925
@@ -1026,6 +1034,7 @@ Now you can call whatever methods are on *your* User object. For example,
1026
1034
if your User object has a ``getFirstName() `` method, you could use that::
1027
1035
1028
1036
use Symfony\Component\HttpFoundation\Response;
1037
+ // ...
1029
1038
1030
1039
public function indexAction()
1031
1040
{
@@ -1359,7 +1368,7 @@ configuration tree may be useful.
1359
1368
1360
1369
Good luck!
1361
1370
1362
- Learn more from the Cookbook
1371
+ Learn More from the Cookbook
1363
1372
----------------------------
1364
1373
1365
1374
* :doc: `Forcing HTTP/HTTPS </cookbook/security/force_https >`
0 commit comments