Hiding Sonata Admin Menu Elements By Role

707 views
Skip to first unread message

Edgar ochieng'

unread,
Jul 10, 2014, 3:15:10 AM7/10/14
to sonata...@googlegroups.com
I have read widely and tried examples but still cannot get the hang of Symfony2 ROLEs and Sonata Admin. I have four levels of users,

 - SuperAdmin which is basically me the developer
 - Admin who is the application owner. He has access to everything except user/ group management. Admin adds an Agency who will get an email with credentials into system
 - Agency who then adds the exployees of people(Facilitators) working for the project
 - Facilitators who are Agency employees who enter field Entries into the system

I want in Sonata Admin, to:

 - Facilitators to only see Entry management menu
 - Agency to see Entry and Facilitator Management menus only
 - Admin to see Agency,Entry and Facilitator management menus only
 - SuperAdmin to see everything else including user and Group management generated by SonataUserBundle

Here is how my security.yml file looks like

    security:
    role_hierarchy:
        ROLE_FACILITATOR:  
            -   ROLE_USER
            -   ROLE_SONATA_ADMIN
            -   ROLE_SONATA_ADMIN_ENTRY_EDIT
            -   ROLE_SONATA_ADMIN_ENTRY_LIST
            -   ROLE_SONATA_ADMIN_ENTRY_CREATE
            -   ROLE_SONATA_ADMIN_ENTRY_VIEW
            -   ROLE_SONATA_ADMIN_ENTRY_DELETE
        ROLE_AGENCY:
            -   ROLE_FACILITATOR
            -   ROLE_SONATA_ADMIN_FACILITATOR_EDIT
            -   ROLE_SONATA_ADMIN_FACILITATOR_LIST
            -   ROLE_SONATA_ADMIN_FACILITATOR_CREATE
            -   ROLE_SONATA_ADMIN_FACILITATOR_VIEW
            -   ROLE_SONATA_ADMIN_FACILITATOR_DELETE
        ROLE_OLX_ADMIN:
            -   ROLE_AGENCY
            -   ROLE_SONATA_ADMIN
            -   ROLE_SONATA_ADMIN_AGENCY_EDIT
            -   ROLE_SONATA_ADMIN_AGENCY_LIST
            -   ROLE_SONATA_ADMIN_AGENCY_CREATE
            -   ROLE_SONATA_ADMIN_AGENCY_VIEW
            -   ROLE_SONATA_ADMIN_AGENCY_DELETE
        ROLE_SUPER_ADMIN:
            -   ROLE_OLX_ADMIN
            -   ROLE_ALLOWED_TO_SWITCHS

 

Cassiano Tartari

unread,
Jul 10, 2014, 6:41:31 AM7/10/14
to sonata-users
And what's going on? What sonata_admin.security.handler are you using? Have you set this ROLEs to groups and set each type of user to these groups?


--
You received this message because you are subscribed to the Google Groups "sonata-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonata-users...@googlegroups.com.
To post to this group, send email to sonata...@googlegroups.com.
Visit this group at http://groups.google.com/group/sonata-users.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Edgar ochieng'

unread,
Jul 12, 2014, 12:02:03 AM7/12/14
to sonata...@googlegroups.com
Sorry I replied to this post yesterday and it disappeared.

I am using sonata.admin.security.handler.role,  where now all menu items disappear. The ROLEs are set up to groups and user assigned to the groups.

I know I am missing something in configuration
Reply all
Reply to author
Forward
0 new messages