Search code examples
symfonybundle

Role management and access rights using symfony3


So i'm working in a big project with symfony 3, But when we wanted to add the users and role managemet and access rights, we had no idea what is the best and optimized procedure to use. So i have this Management project and i want to add user and roles so that some users can access some actions and the others not. I have more than 10 profiles and each profile has a specific access rights. So i thought maybe you can help me by telling me what are the methods and bundles avalaibale in symfony, so that i can pick one after a benchmarking. thanks a lot


Solution

  • I think you should read this article about Access Control Lists. It explains how to decide access by user and domain object. As stated in the article, it is not trivial, so an alternative is to use Voters. Here is a snippet on using Voters:

    A voter is passed the object being voted on, which you can use to make complex decisions and effectively implement your own ACL. Enforcing authorization (e.g. the isGranted() part) will look similar to what you see in this entry, but your voter class will handle the logic behind the scenes, instead of the ACL system.

    I would urge you to consider this path instead of searching for a bundle as it is fairly easy to set up and gives you a pretty good control over access rights.