Skip to content

Commit c401da4

Browse files
Changed uses of we in security cookbooks
1 parent b79e123 commit c401da4

File tree

6 files changed

+64
-64
lines changed

6 files changed

+64
-64
lines changed

cookbook/security/acl.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ the ACL system comes in.
1212
Imagine you are designing a blog system where your users can comment on your
1313
posts. Now, you want a user to be able to edit his own comments, but not those
1414
of other users; besides, you yourself want to be able to edit all comments. In
15-
this scenario, ``Comment`` would be our domain object that you want to
15+
this scenario, ``Comment`` would be the domain object that you want to
1616
restrict access to. You could take several approaches to accomplish this using
1717
Symfony2, two basic approaches are (non-exhaustive):
1818

@@ -27,13 +27,13 @@ logic to your business code which makes it less reusable elsewhere, and also
2727
increases the difficulty of unit testing. Besides, you could run into
2828
performance issues if many users would have access to a single domain object.
2929

30-
Fortunately, there is a better way, which we will talk about now.
30+
Fortunately, there is a better way, which you will find out about now.
3131

3232
Bootstrapping
3333
-------------
3434

35-
Now, before we finally can get into action, we need to do some bootstrapping.
36-
First, we need to configure the connection the ACL system is supposed to use:
35+
Now, before you can finally get into action, you need to do some bootstrapping.
36+
First, you need to configure the connection the ACL system is supposed to use:
3737

3838
.. configuration-block::
3939

@@ -67,8 +67,8 @@ First, we need to configure the connection the ACL system is supposed to use:
6767
domain objects. You can use whatever mapper you like for your objects, be it
6868
Doctrine ORM, MongoDB ODM, Propel, raw SQL, etc. The choice is yours.
6969

70-
After the connection is configured, we have to import the database structure.
71-
Fortunately, we have a task for this. Simply run the following command:
70+
After the connection is configured, you have to import the database structure.
71+
Fortunately, there is a task for this. Simply run the following command:
7272

7373
.. code-block:: bash
7474
@@ -77,7 +77,7 @@ Fortunately, we have a task for this. Simply run the following command:
7777
Getting Started
7878
---------------
7979

80-
Coming back to our small example from the beginning, let's implement ACL for
80+
Coming back to the small example from the beginning, let's implement ACL for
8181
it.
8282

8383
Creating an ACL, and adding an ACE
@@ -136,11 +136,11 @@ have no actual domain object instance at hand. This will be extremely helpful
136136
if you want to check permissions for a large number of objects without
137137
actually hydrating these objects.
138138

139-
The other interesting part is the ``->insertObjectAce()`` call. In our
140-
example, we are granting the user who is currently logged in owner access to
139+
The other interesting part is the ``->insertObjectAce()`` call. In the
140+
example, you are granting the user who is currently logged in owner access to
141141
the Comment. The ``MaskBuilder::MASK_OWNER`` is a pre-defined integer bitmask;
142142
don't worry the mask builder will abstract away most of the technical details,
143-
but using this technique we can store many different permissions in one
143+
but using this technique you can store many different permissions in one
144144
database row which gives us a considerable boost in performance.
145145

146146
.. tip::
@@ -175,7 +175,7 @@ Checking Access
175175
}
176176
}
177177
178-
In this example, we check whether the user has the ``EDIT`` permission.
178+
In this example, you check whether the user has the ``EDIT`` permission.
179179
Internally, Symfony2 maps the permission to several integer bitmasks, and
180180
checks whether the user has any of them.
181181

@@ -188,10 +188,10 @@ checks whether the user has any of them.
188188
Cumulative Permissions
189189
----------------------
190190

191-
In our first example above, we only granted the user the ``OWNER`` base
191+
In the first example above, you only granted the user the ``OWNER`` base
192192
permission. While this effectively also allows the user to perform any
193193
operation such as view, edit, etc. on the domain object, there are cases where
194-
we want to grant these permissions explicitly.
194+
you may want to grant these permissions explicitly.
195195

196196
The ``MaskBuilder`` can be used for creating bit masks easily by combining
197197
several base permissions:

cookbook/security/acl_advanced.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ objectives:
2424
As indicated by the first point, one of the main capabilities of Symfony2's
2525
ACL system is a high-performance way of retrieving ACLs/ACEs. This is
2626
extremely important since each ACL might have several ACEs, and inherit from
27-
another ACL in a tree-like fashion. Therefore, we specifically do not leverage
28-
any ORM, but the default implementation interacts with your connection
29-
directly using Doctrine's DBAL.
27+
another ACL in a tree-like fashion. Therefore, no ORM is leveraged, instead
28+
the default implementation interacts with your connection directly using Doctrine's
29+
DBAL.
3030

3131
Object Identities
3232
~~~~~~~~~~~~~~~~~
@@ -71,16 +71,16 @@ Scope of Access Control Entries
7171
-------------------------------
7272

7373
Access control entries can have different scopes in which they apply. In
74-
Symfony2, we have basically two different scopes:
74+
Symfony2, there are basically two different scopes:
7575

7676
- Class-Scope: These entries apply to all objects with the same class.
77-
- Object-Scope: This was the scope we solely used in the previous chapter, and
77+
- Object-Scope: This was the scope solely used in the previous chapter, and
7878
it only applies to one specific object.
7979

8080
Sometimes, you will find the need to apply an ACE only to a specific field of
8181
the object. Let's say you want the ID only to be viewable by an administrator,
82-
but not by your customer service. To solve this common problem, we have added
83-
two more sub-scopes:
82+
but not by your customer service. To solve this common problem, two more sub-scopes
83+
have been added:
8484

8585
- Class-Field-Scope: These entries apply to all objects with the same class,
8686
but only to a specific field of the objects.
@@ -91,10 +91,10 @@ Pre-Authorization Decisions
9191
---------------------------
9292

9393
For pre-authorization decisions, that is decisions made before any secure method (or
94-
secure action) is invoked, we rely on the proven AccessDecisionManager service
95-
that is also used for reaching authorization decisions based on roles. Just
96-
like roles, the ACL system adds several new attributes which may be used to
97-
check for different permissions.
94+
secure action) is invoked, the proven AccessDecisionManager service is used.
95+
The AccessDecisionManager is also used for reaching authorization decisions based
96+
on roles. Just like roles, the ACL system adds several new attributes which may be
97+
used to check for different permissions.
9898

9999
Built-in Permission Map
100100
~~~~~~~~~~~~~~~~~~~~~~~
@@ -153,8 +153,8 @@ Extensibility
153153

154154
The above permission map is by no means static, and theoretically could be
155155
completely replaced at will. However, it should cover most problems you
156-
encounter, and for interoperability with other bundles, we encourage you to
157-
stick to the meaning we have envisaged for them.
156+
encounter, and for interoperability with other bundles, you are encouraged to
157+
stick to the meaning envisaged for them.
158158

159159
Post Authorization Decisions
160160
----------------------------

cookbook/security/custom_authentication_provider.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ The Token
4545
The role of the token in the Symfony2 security context is an important one.
4646
A token represents the user authentication data present in the request. Once
4747
a request is authenticated, the token retains the user's data, and delivers
48-
this data across the security context. First, we will create our token class.
49-
This will allow the passing of all relevant information to our authentication
48+
this data across the security context. First, you'll create your token class.
49+
This will allow the passing of all relevant information to your authentication
5050
provider.
5151

5252
.. code-block:: php
@@ -332,7 +332,7 @@ a firewall in your security configuration.
332332

333333
.. note::
334334

335-
You may be wondering "why do we need a special factory class to add listeners
335+
You may be wondering "why do you need a special factory class to add listeners
336336
and providers to the dependency injection container?". This is a very
337337
good question. The reason is you can use your firewall multiple times,
338338
to secure multiple parts of your application. Because of this, each

cookbook/security/custom_provider.rst

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ the configured user provider to return a user object for a given username.
1010
Symfony then checks whether the password of this user is correct and generates
1111
a security token so the user stays authenticated during the current session.
1212
Out of the box, Symfony has an "in_memory" and an "entity" user provider.
13-
In this entry we'll see how you can create your own user provider, which
13+
In this entry you'll see how you can create your own user provider, which
1414
could be useful if your users are accessed via a custom database, a file,
15-
or - as we show in this example - a web service.
15+
or - as shown in this example - a web service.
1616

1717
Create a User Class
1818
-------------------
@@ -21,7 +21,7 @@ First, regardless of *where* your user data is coming from, you'll need to
2121
create a ``User`` class that represents that data. The ``User`` can look
2222
however you want and contain any data. The only requirement is that the
2323
class implements :class:`Symfony\\Component\\Security\\Core\\User\\UserInterface`.
24-
The methods in this interface should therefore be defined in the custom user
24+
The methods in this interface should therefore be defined in the custom user
2525
class: ``getRoles()``, ``getPassword()``, ``getSalt()``, ``getUsername()``,
2626
``eraseCredentials()``, ``equals()``.
2727

@@ -101,12 +101,12 @@ For more details on each of the methods, see :class:`Symfony\\Component\\Securit
101101
Create a User Provider
102102
----------------------
103103

104-
Now that we have a ``User`` class, we'll create a user provider, which will
104+
Now that you have a ``User`` class, you'll create a user provider, which will
105105
grab user information from some web service, create a ``WebserviceUser`` object,
106106
and populate it with data.
107107

108-
The user provider is just a plain PHP class that has to implement the
109-
:class:`Symfony\\Component\\Security\\Core\\User\\UserProviderInterface`,
108+
The user provider is just a plain PHP class that has to implement the
109+
:class:`Symfony\\Component\\Security\\Core\\User\\UserProviderInterface`,
110110
which requires three methods to be defined: ``loadUserByUsername($username)``,
111111
``refreshUser(UserInterface $user)``, and ``supportsClass($class)``. For
112112
more details, see :class:`Symfony\\Component\\Security\\Core\\User\\UserProviderInterface`.
@@ -158,7 +158,7 @@ Here's an example of how this might look::
158158
Create a Service for the User Provider
159159
--------------------------------------
160160

161-
Now we make the user provider available as a service.
161+
Now you make the user provider available as a service:
162162

163163
.. configuration-block::
164164

@@ -167,29 +167,29 @@ Now we make the user provider available as a service.
167167
# src/Acme/WebserviceUserBundle/Resources/config/services.yml
168168
parameters:
169169
webservice_user_provider.class: Acme\WebserviceUserBundle\Security\User\WebserviceUserProvider
170-
170+
171171
services:
172172
webservice_user_provider:
173173
class: "%webservice_user_provider.class%"
174-
174+
175175
.. code-block:: xml
176176
177177
<!-- src/Acme/WebserviceUserBundle/Resources/config/services.xml -->
178178
<parameters>
179179
<parameter key="webservice_user_provider.class">Acme\WebserviceUserBundle\Security\User\WebserviceUserProvider</parameter>
180180
</parameters>
181-
181+
182182
<services>
183183
<service id="webservice_user_provider" class="%webservice_user_provider.class%"></service>
184184
</services>
185-
185+
186186
.. code-block:: php
187-
187+
188188
// src/Acme/WebserviceUserBundle/Resources/config/services.php
189189
use Symfony\Component\DependencyInjection\Definition;
190-
190+
191191
$container->setParameter('webservice_user_provider.class', 'Acme\WebserviceUserBundle\Security\User\WebserviceUserProvider');
192-
192+
193193
$container->setDefinition('webservice_user_provider', new Definition('%webservice_user_provider.class%');
194194
195195
.. tip::
@@ -207,7 +207,7 @@ Modify ``security.yml``
207207
-----------------------
208208

209209
In ``/app/config/security.yml`` everything comes together. Add the user provider
210-
to the list of providers in the "security" section. Choose a name for the user provider
210+
to the list of providers in the "security" section. Choose a name for the user provider
211211
(e.g. "webservice") and mention the id of the service you just defined.
212212

213213
.. code-block:: yaml
@@ -218,8 +218,8 @@ to the list of providers in the "security" section. Choose a name for the user p
218218
id: webservice_user_provider
219219
220220
Symfony also needs to know how to encode passwords that are supplied by website
221-
users, e.g. by filling in a login form. You can do this by adding a line to the
222-
"encoders" section in ``/app/config/security.yml``.
221+
users, e.g. by filling in a login form. You can do this by adding a line to the
222+
"encoders" section in ``/app/config/security.yml``.
223223

224224
.. code-block:: yaml
225225
@@ -241,21 +241,21 @@ options, the password may be encoded multiple times and encoded to base64.
241241
nothing, then the submitted password is simply encoded using the algorithm
242242
you specify in ``security.yml``. If a salt *is* specified, then the following
243243
value is created and *then* hashed via the algorithm:
244-
244+
245245
``$password.'{'.$salt.'}';``
246246

247247
If your external users have their passwords salted via a different method,
248248
then you'll need to do a bit more work so that Symfony properly encodes
249249
the password. That is beyond the scope of this entry, but would include
250250
sub-classing ``MessageDigestPasswordEncoder`` and overriding the ``mergePasswordAndSalt``
251251
method.
252-
252+
253253
Additionally, the hash, by default, is encoded multiple times and encoded
254254
to base64. For specific details, see `MessageDigestPasswordEncoder`_.
255255
To prevent this, configure it in ``security.yml``:
256-
256+
257257
.. code-block:: yaml
258-
258+
259259
security:
260260
encoders:
261261
Acme\WebserviceUserBundle\Security\User\WebserviceUser:

cookbook/security/entity_provider.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ For more details on each of these, see :class:`Symfony\\Component\\Security\\Cor
159159
To keep it simple, the ``equals()`` method just compares the ``username`` field
160160
but it's also possible to do more checks depending on the complexity of your
161161
data model. On the other hand, the ``eraseCredentials()`` method remains empty
162-
as we don't care about it in this tutorial.
162+
for the purposes of this tutorial.
163163

164164
Below is an export of my ``User`` table from MySQL. For details on how to
165165
create user records and encode their password, see :ref:`book-security-encoding-user-password`.
@@ -192,7 +192,7 @@ layer is a piece of cake. Everything resides in the configuration of the
192192

193193
Below is an example of configuration where the user will enter his/her
194194
username and password via HTTP basic authentication. That information will
195-
then be checked against our User entity records in the database:
195+
then be checked against your User entity records in the database:
196196

197197
.. configuration-block::
198198

@@ -236,7 +236,7 @@ the ``username`` unique field. In other words, this tells Symfony how to
236236
fetch the user from the database before checking the password validity.
237237

238238
This code and configuration works but it's not enough to secure the application
239-
for **active** users. As of now, we still can authenticate with ``maxime``. The
239+
for **active** users. As of now, you can still authenticate with ``maxime``. The
240240
next section explains how to forbid non active users.
241241

242242
Forbid non Active Users
@@ -295,7 +295,7 @@ For this example, the first three methods will return ``true`` whereas the
295295
}
296296
}
297297
298-
If we try to authenticate a ``maxime``, the access is now forbidden as this
298+
If you try to authenticate as ``maxime``, the access is now forbidden as this
299299
user does not have an enabled account. The next session will focus on how
300300
to write a custom entity provider to authenticate a user with his username
301301
or his email address.
@@ -400,7 +400,7 @@ from the database. As mentioned previously, when your user is loaded, its
400400
``getRoles()`` method returns the array of security roles that should be
401401
assigned to the user. You can load this data from anywhere - a hardcoded
402402
list used for all users (e.g. ``array('ROLE_USER')``), a Doctrine array
403-
property called ``roles``, or via a Doctrine relationship, as we'll learn
403+
property called ``roles``, or via a Doctrine relationship, as you'll learn
404404
about in this section.
405405

406406
.. caution::

cookbook/security/voters.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ values:
4545
* ``VoterInterface::ACCESS_ABSTAIN``: The voter cannot decide if the user is granted or not
4646
* ``VoterInterface::ACCESS_DENIED``: The user is not allowed to access the application
4747

48-
In this example, we will check if the user's IP address matches against a list of
49-
blacklisted addresses. If the user's IP is blacklisted, we will return
50-
``VoterInterface::ACCESS_DENIED``, otherwise we will return
48+
In this example, you'll check if the user's IP address matches against a list of
49+
blacklisted addresses. If the user's IP is blacklisted, you'll return
50+
``VoterInterface::ACCESS_DENIED``, otherwise you'll return
5151
``VoterInterface::ACCESS_ABSTAIN`` as this voter's purpose is only to deny
5252
access, not to grant access.
5353

5454
Creating a Custom Voter
5555
-----------------------
5656

57-
To blacklist a user based on its IP, we can use the ``request`` service
57+
To blacklist a user based on its IP, you can use the ``request`` service
5858
and compare the IP address against a set of blacklisted IP addresses:
5959

6060
.. code-block:: php
@@ -76,13 +76,13 @@ and compare the IP address against a set of blacklisted IP addresses:
7676
7777
public function supportsAttribute($attribute)
7878
{
79-
// we won't check against a user attribute, so we return true
79+
// you won't check against a user attribute, so return true
8080
return true;
8181
}
8282
8383
public function supportsClass($class)
8484
{
85-
// our voter supports all type of token classes, so we return true
85+
// your voter supports all type of token classes, so return true
8686
return true;
8787
}
8888
@@ -103,7 +103,7 @@ the security layer. This can be done easily through the service container.
103103
Declaring the Voter as a Service
104104
--------------------------------
105105

106-
To inject the voter into the security layer, we must declare it as a service,
106+
To inject the voter into the security layer, you must declare it as a service,
107107
and tag it as a "security.voter":
108108

109109
.. configuration-block::
@@ -160,11 +160,11 @@ and tag it as a "security.voter":
160160
Changing the Access Decision Strategy
161161
-------------------------------------
162162

163-
In order for the new voter to take effect, we need to change the default access
163+
In order for the new voter to take effect, you need to change the default access
164164
decision strategy, which, by default, grants access if *any* voter grants
165165
access.
166166

167-
In our case, we will choose the ``unanimous`` strategy. Unlike the ``affirmative``
167+
In this case, choose the ``unanimous`` strategy. Unlike the ``affirmative``
168168
strategy (the default), with the ``unanimous`` strategy, if only one voter
169169
denies access (e.g. the ``ClientIpVoter``), access is not granted to the
170170
end user.

0 commit comments

Comments
 (0)