1

I have a question about Symfony2, I Hope someone could help me.

I'm developing an application where the Administrator user has to be able to create new roles with new privileges. In other words, the app/security.yml file will change every time the Administrator creates a new role. I'd like to know how I can do that... or if there is a Bundle that could help me with this.

Ryan Berger
  • 9,644
  • 6
  • 44
  • 56
juansneak
  • 37
  • 2
  • 6

2 Answers2

0

Create your own user entity extends UserInterface and then custom the function getRoles();

Take a look at http://php-and-symfony.matthiasnoback.nl/2012/07/symfony2-security-creating-dynamic-roles-using-roleinterface/

Pierre
  • 776
  • 6
  • 27
0

You may want to use ACL's.

But it depends on what you are doing with the roles. Why is the Admin creating new Roles? What permissions do they grant? The Roles typically protect routes, and I don't know a way to dynamically define routes from some sort of Admin interface (out of the box). So I'm guessing you want to give users permissions to do various things. So I think you want to look at ACL's.

Matt
  • 5,478
  • 9
  • 56
  • 95