Symfony 页面上的官方文档建议在 ACL 调用中使用 ROLE_ADMIN (example) 属性
$this->denyAccessUnlessGranted('ROLE_ADMIN', null, 'Unable to access this page!');
我的问题是是否可以使用没有 ROLE_ 前缀的 ACL 调用。
问题是我们有多个没有 ROLES 但具有“USER.CREATE”或“USER_CREATE”权限的系统,这将保护 UserController 中的路由 POST /user/create 和 action Create()。
最好的解决方案是有一个投票者,它将 ACL 称为
$objectName = 'USER';
$action = 'CREATE';
$this->denyAccessUnlessGranted($objectName. '_'. $action, null, 'Unable to access this page!');
但这不起作用,因为一切都依赖于 ROLE_ 前缀。有没有人试图实现这样的目标?