4

I am working on a Symfony project where I have to manage roles. I want to use Sonata ACL but can't make it work.

An user with ROLE_CONTACT should be able to list, create and edit an user, but he can only list and add users.

I followed the documentation here.

Here is my code.

security.yml

 role_hierarchy:
        ROLE_TRADUCTEUR:      [ROLE_USER]
        ROLE_CONTACT:
          - ROLE_SONATA_ADMIN
          - ROLE_SONATA_ADMIN_USER_STAFF
          - ...
    acl:
        connection: default 

services.yml

parameters:
#    parameter_name: value
    security.acl.permission.map.class: Sonata\AdminBundle\Security\Acl\Permission\AdminPermissionMap
    sonata.admin.security.mask.builder.class: Sonata\AdminBundle\Security\Acl\Permission\MaskBuilder

sonata_admin.yml (included in config.yml)

sonata_admin:
    templates:
        layout:  SonataAdminBundle::extend_layout.html.twig
    security:
        handler: sonata.admin.security.handler.acl
        # acl security information
        information:
            GUEST:    [VIEW, LIST]
            STAFF:    [EDIT, LIST, CREATE]
            EDITOR:   [OPERATOR, EXPORT]
            ADMIN:    [MASTER]

        # permissions not related to an object instance and also to be available when objects do not exist
        # the DELETE admin permission means the user is allowed to batch delete objects
        admin_permissions: [CREATE, LIST, DELETE, UNDELETE, EXPORT, OPERATOR, MASTER]

        # permission related to the objects
        object_permissions: [VIEW, EDIT, DELETE, UNDELETE, OPERATOR, MASTER, OWNER]

Can you help me ? Thank you

Sylvain
  • 85
  • 9
  • Can you show us what ROLE_SONATA_ADMIN can do?, and where is that declare. Did you try change ROLE_SONATA_ADMIN to ROLE_ADMIN ?? – Andrzej Piszczek Jun 02 '16 at 13:06
  • If i'm right (I don't started this project, and I'm learning Sonata), ROLE_SONATA_ADMIN is defined by SonataAdminBundle, isn't it ? And yes, I tried to change with ROLE_ADMIN, but then I can't connect, because Sonata require ROLE_SONATA_ADMIN to connect to the backoffice – Sylvain Jun 03 '16 at 06:53

0 Answers0