-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Facelifted book/security #2783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Facelifted book/security #2783
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ad8267b
Fixed formatting issue
wouterj 239a6e9
Changed link to docs instead of code
wouterj b377ecf
Removed repeating text
wouterj 42cbad2
Removed "see section X" caution
wouterj c58d1be
Improved list
wouterj a79617b
Improved code readability
wouterj b3cc1ed
Moved caution directive to not break colon
wouterj 75fdf55
Do not break twig syntax
wouterj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,8 +25,8 @@ application with HTTP Basic authentication. | |
|
||
.. note:: | ||
|
||
`Symfony's security component`_ is available as a standalone PHP library | ||
for use inside any PHP project. | ||
:doc:`Symfony's security component </components/security/introduction>` is | ||
available as a standalone PHP library for use inside any PHP project. | ||
|
||
Basic Example: HTTP Authentication | ||
---------------------------------- | ||
|
@@ -415,7 +415,7 @@ submission (i.e. ``/login_check``): | |
``check_path`` ``logout`` keys. These keys can be route names (as shown | ||
in this example) or URLs that have routes configured for them. | ||
|
||
Notice that the name of the ``login`` route matches the``login_path`` config | ||
Notice that the name of the ``login`` route matches the ``login_path`` config | ||
value, as that's where the security system will redirect users that need | ||
to login. | ||
|
||
|
@@ -674,14 +674,11 @@ see :doc:`/cookbook/security/form_login`. | |
Authorization | ||
------------- | ||
|
||
The first step in security is always authentication: the process of verifying | ||
who the user is. With Symfony, authentication can be done in any way - via | ||
a form login, basic HTTP Authentication, or even via Facebook. | ||
|
||
Once the user has been authenticated, authorization begins. Authorization | ||
provides a standard and powerful way to decide if a user can access any resource | ||
(a URL, a model object, a method call, ...). This works by assigning specific | ||
roles to each user, and then requiring different roles for different resources. | ||
The first step in security is always authentication. Once the user has been | ||
authenticated, authorization begins. Authorization provides a standard and | ||
powerful way to decide if a user can access any resource (a URL, a model | ||
object, a method call, ...). This works by assigning specific roles to each | ||
user, and then requiring different roles for different resources. | ||
|
||
The process of authorization has two different sides: | ||
|
||
|
@@ -700,12 +697,6 @@ URL pattern. You've seen this already in the first example of this chapter, | |
where anything matching the regular expression pattern ``^/admin`` requires | ||
the ``ROLE_ADMIN`` role. | ||
|
||
.. caution:: | ||
|
||
Understanding exactly how ``access_control`` works is **very** important | ||
to make sure your application is properly secured. See :ref:`security-book-access-control-explanation` | ||
below for detailed information. | ||
|
||
You can define as many URL patterns as you need - each is a regular expression. | ||
|
||
.. configuration-block:: | ||
|
@@ -757,12 +748,15 @@ to find *one* that matches the current request. As soon as it finds a matching | |
is used to enforce access. | ||
|
||
Each ``access_control`` has several options that configure two different | ||
things: (a) :ref:`should the incoming request match this access control entry<security-book-access-control-matching-options>` | ||
and (b) :ref:`once it matches, should some sort of access restriction be enforced<security-book-access-control-enforcement-options>`: | ||
things: | ||
|
||
* :ref:`should the incoming request match this access control entry<security-book-access-control-matching-options>` | ||
* :ref:`once it matches, should some sort of access restriction be enforced<security-book-access-control-enforcement-options>`: | ||
|
||
.. _security-book-access-control-matching-options: | ||
|
||
**(a) Matching Options** | ||
Matching Options | ||
................ | ||
|
||
Symfony2 creates an instance of :class:`Symfony\\Component\\HttpFoundation\\RequestMatcher` | ||
for each ``access_control`` entry, which determines whether or not a given | ||
|
@@ -842,7 +836,8 @@ will match any ``ip``, ``host`` or ``method``: | |
|
||
.. _security-book-access-control-enforcement-options: | ||
|
||
**(b) Access Enforcement** | ||
Access Enforcement | ||
.................. | ||
|
||
Once Symfony2 has decided which ``access_control`` entry matches (if any), | ||
it then *enforces* access restrictions based on the ``roles`` and ``requires_channel`` | ||
|
@@ -1185,7 +1180,9 @@ class: | |
security: | ||
providers: | ||
main: | ||
entity: { class: Acme\UserBundle\Entity\User, property: username } | ||
entity: | ||
class: Acme\UserBundle\Entity\User | ||
property: username | ||
|
||
.. code-block:: xml | ||
|
||
|
@@ -1202,7 +1199,10 @@ class: | |
$container->loadFromExtension('security', array( | ||
'providers' => array( | ||
'main' => array( | ||
'entity' => array('class' => 'Acme\UserBundle\Entity\User', 'property' => 'username'), | ||
'entity' => array( | ||
'class' => 'Acme\UserBundle\Entity\User', | ||
'property' => 'username', | ||
), | ||
), | ||
), | ||
)); | ||
|
@@ -1705,11 +1705,6 @@ Note that you will *not* need to implement a controller for the ``/logout`` | |
URL as the firewall takes care of everything. You *do*, however, need to create | ||
a route so that you can use it to generate the URL: | ||
|
||
.. caution:: | ||
|
||
As of Symfony 2.1, you *must* have a route that corresponds to your logout | ||
path. Without this route, logging out will not work. | ||
|
||
.. configuration-block:: | ||
|
||
.. code-block:: yaml | ||
|
@@ -1742,6 +1737,11 @@ a route so that you can use it to generate the URL: | |
|
||
return $collection; | ||
|
||
.. caution:: | ||
|
||
As of Symfony 2.1, you *must* have a route that corresponds to your logout | ||
path. Without this route, logging out will not work. | ||
|
||
Once the user has been logged out, he will be redirected to whatever path | ||
is defined by the ``target`` parameter above (e.g. the ``homepage``). For | ||
more information on configuring the logout, see the | ||
|
@@ -1861,7 +1861,7 @@ to show a link to exit impersonation: | |
.. code-block:: html+jinja | ||
|
||
{% if is_granted('ROLE_PREVIOUS_ADMIN') %} | ||
<a href="{{ path('homepage', {_switch_user: '_exit'}) }}">Exit impersonation</a> | ||
<a href="{{ path('homepage', {'_switch_user': '_exit'}) }}">Exit impersonation</a> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this change is not needed (unless you use an old Txig version) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is, it's invalid jinja and thus it isn't highlighted on the website |
||
{% endif %} | ||
|
||
.. code-block:: html+php | ||
|
@@ -2040,7 +2040,6 @@ Learn more from the Cookbook | |
* :doc:`Access Control Lists (ACLs) </cookbook/security/acl>` | ||
* :doc:`/cookbook/security/remember_me` | ||
|
||
.. _`Symfony's security component`: https://github.com/symfony/Security | ||
.. _`JMSSecurityExtraBundle`: http://jmsyst.com/bundles/JMSSecurityExtraBundle/1.2 | ||
.. _`FOSUserBundle`: https://github.com/FriendsOfSymfony/FOSUserBundle | ||
.. _`implement the \Serializable interface`: http://php.net/manual/en/class.serializable.php | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we remove the
As of Symfony 2.1
as 2.0 is not maintained anymore ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only from bramches which are released after the deprecation. In this case, it's 2.3