Symfony2: Storing users, roles, role hierarchy, and access controls in database

zeitgeist picture zeitgeist · Nov 18, 2011 · Viewed 15.3k times · Source

I've been working with Symfony (2.x) for the first time and I had some questions regarding the definition of roles, role hierarchy, and how they can be assigned to individual users.

I was interested in storing the roles and role hierarchy in a database (rather than security.yml); however, I cannot find any documentation supporting this. Is this advisable?

I was interested in having an admin module that can add new roles and define role hierarchies; however, having the admin module modify security.yml or some other config file seems like a bad idea.

This obviously would require that the ACLs can be stored in a database as well.

  • Does anyone have any tips or documentation that might help with this?
  • Is it a bad idea, performance wise?

I've been successful implementing this with Zend Framework in the past and was hoping to do the same with Symfony2.

Answer

mcandril picture mcandril · Nov 18, 2011

Perhaps you might want to have a look at FOSUserBundle