Topics
- OroSecurityBundle (annotations, protecting ORM queries and grids)
- OroEntityConfigBundle
Changes
src/Acme/Bundle/TaskBundle
Controller
TaskController (updated, added ACL annotations)
Entity
Task (updated, added ACL annotations)
Resources
config
datagrid.yml (updated, added ACL configuration)
views
Task
create.html.twig (updated, added security checks)
update.html.twig (updated, added security checks)
view.html.twig (updated, added security checks)
searchResult.html.twig (updated, added security checks)
- Add annotation to Acme\Bundle\TaskBundle\Entity\Task:
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation as OroEntityConfig;
/**
* @OroEntityConfig\Config(
* defaultValues={
* "ownership"={
* "owner_type"="USER",
* "owner_field_name"="owner",
* "owner_column_name"="owner_id"
* },
* "security"={
* "type"="ACL"
* }
* }
*/
-
Run command oro:entity-config:update
-
Update Acme\Bundle\TaskBundle\Controller\TaskController
Add ACL annotations:
/**
* @Acl(
* id="acme_task_index",
* type="entity",
* class="AcmeTaskBundle:Task",
* permission="VIEW"
* )
*/
Remove code to handle owner from createAction method
-
Run command cache:clear
-
Ensure that at least one task is owned by your user
-
Go to System -> User management -> Roles, select Administrator and check Task
-
Change VIEW permission for Task from "System" to "User" and check how Tasks grid automatically protects users, change VIEW to "System" again
-
Change EDIT permission in Administrator role for Task from "System" to "User" and check permission error when you click on edit users
-
Change CREATE permission in Administrator role for Task from "System" to "User" and check how you can create Tasks only with your user as owner
-
Change ASSIGN permission in Administrator role for Task from "System" to "User" and check how you can change Task owner only to your user
-
Update Add ACL configuration to datagrid.yml
-
Change EDIT permission in Administrator role for Task to "None" and check how edit actions are not showing in grid
-
Add ACL checks to templates
-
Change ACL permissions and check UI on tasks pages for elements that are protected now