How to dynamic handle roles|permissions in Symfony2 at database level: CRUD operations over them

316 views
Skip to first unread message

reyn...@gmail.com

unread,
Dec 9, 2015, 1:07:40 PM12/9/15
to sonata...@googlegroups.com
I am working in a Symfony 2.8 project and I have a doubt regarding users/groups/roles|permissions. There are a few ways to handle users and groups as for example [SonataUser][1] on top of [SonataAdmin][2] and lately [EasyAdmin][3] but all of them lacks ROLE|permissions management and this is exactly my doubt: what's the proper way to handle them? Yes, I know I need to write them at `security.yml` but I don't know if I can store then in DB (somewhere) and then read from there. I have research about this and found ACL, Voters and so on but instead of clear my mind the research is confusing me a lot so I need some push from people here. Then:

 - How would you handle this?
 - Any example at code level? (I prefer to see something other than words to get the whole point)
 - Are ROLES sames as permissions?

**Update: improve question**

What I want to have is a `ManyToMany` relationship between `users` and `roles` and possibly `groups` and `roles`. I think that as `SonataUserBundle` handle this is by creating a column `roles` in `user` table and assign a lot of roles to each user, even create new ones if I'm not mistaken but what about if I want to create as much roles as I can without assign them to a user and later add many roles to a user even to a group? 

How would you do that?


Reply all
Reply to author
Forward
0 new messages