Skip to content

Commit 74897e3

Browse files
committed
[#2989] Moving the message about ACL alternatives higher up and furthering the message
1 parent 3324e1c commit 74897e3

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

cookbook/security/acl.rst

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ cannot only be based on the person (``Token``) who is requesting access, but
99
also involve a domain object that access is being requested for. This is where
1010
the ACL system comes in.
1111

12+
.. sidebar:: Alternatives to ACLS
13+
14+
Using ACL's isn't trivial, and for simpler use cases, it may be overkill.
15+
If your permission logic could be described by just writing some code (e.g.
16+
to check if a Blog is owned by the current User), then consider using
17+
:doc:`voters </cookbook/security/voters>`. A voter is passed the object
18+
being voted on, which you can use to make complex decisions and effectively
19+
implement your own ACL. Enforcing authorization (e.g. the ``isGranted``
20+
part) will look similar to what you see in this entry, but your voter
21+
class will handle the logic behind the scenes, instead of the ACL system.
22+
1223
Imagine you are designing a blog system where your users can comment on your
1324
posts. Now, you want a user to be able to edit his own comments, but not those
1425
of other users; besides, you yourself want to be able to edit all comments. In
@@ -215,16 +226,4 @@ added above:
215226
216227
The user is now allowed to view, edit, delete, and un-delete objects.
217228

218-
Looking for Alternatives
219-
------------------------
220-
221-
For more simple use cases this seems to be an overhead for many developers.
222-
As a downside there is that in case you change the permissions in any way,
223-
you need to change all the existing granted permissions as well. As well
224-
when you want to change a specific part of the ACL you need to understand
225-
the structure and process of this complex voter. So you should consider if
226-
a classical and simple conditional permission check would fit for you.
227-
Some do it with the existing voter ":doc:`/cookbook/security/voters`"
228-
structure as well, or a custom build solutions.
229-
230229
.. _`MongoDBAclBundle`: https://github.com/IamPersistent/MongoDBAclBundle

0 commit comments

Comments
 (0)