Skip to content

Commit 18678c3

Browse files
author
Amrouche Hamza
committed
add explanation
1 parent 65741ea commit 18678c3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/security.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ use Symfony\Component\Validator\Constraints as Assert;
2222
* attributes={"is_granted"="has_role('ROLE_USER')"},
2323
* collectionOperations={
2424
* "get"={"method"="GET"},
25-
* "post"={"method"="POST", "is_granted"="has_role('ROLE_ADMIN')"}
25+
* "post"={"method"="POST", "access_control"="has_role('ROLE_ADMIN')"}
2626
* },
2727
* itemOperations={
28-
* "get"={"method"="GET", "is_granted"="has_role('ROLE_USER') and object.getOwner() == user"}
28+
* "get"={"method"="GET", "access_control"="has_role('ROLE_USER') and object.getOwner() == user"}
2929
* }
3030
* )
3131
* @ORM\Entity
@@ -51,6 +51,8 @@ class Book
5151
}
5252
```
5353

54+
This exemple is going to allow only fetching the book related to the current user, if he try to fetch a book that is not linked to his account that will not return the resource and only admins are able to create books which means that a user could not create a book.
55+
5456
It is also possible to use the [event system](events.md) for more advanced logic or even [custom actions](operations.md#creating-custom-operations-and-controllers)
5557
if you really need to.
5658

0 commit comments

Comments
 (0)