使用 symfony3 进行角色管理和访问权限

Role management and access rights using symfony3

所以我正在使用 symfony 3 在一个大项目中工作,但是当我们想要添加用户和角色管理以及访问权限时,我们不知道什么是最好的和优化的程序。 所以我有这个管理项目,我想添加用户和角色,以便某些用户可以访问某些操作,而其他用户则不能。我有超过 10 个配置文件,每个配置文件都有特定的访问权限。 所以我想也许你可以通过告诉我 symfony 中的方法和捆绑包 avalaibale 来帮助我,这样我就可以在基准测试后选择一个。非常感谢

我认为您应该阅读这篇关于 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 的文章。以下是使用 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.

我建议您考虑这条路径而不是搜索捆绑包,因为它设置起来相当容易,并且可以很好地控制访问权限。