[英]How can i use access security for class fields in symfony2
I have the following scenario. 我有以下情况。
I have 15 type of ROLES for security like ROLE_1 , ROLE_2 ..... ROLE_15
我有15种ROLES类型的安全性,如
ROLE_1 , ROLE_2 ..... ROLE_15
Now i have the complex matrix where each field of entity has 5 different permission for each role 现在我有了一个复杂的矩阵,其中实体的每个字段对每个角色都有5个不同的权限
LIKE 喜欢
view , delete, readonly, undelete, edit, update
e,g for ID
ROLE_1
HAS VIEW
PERMISSION 例如,
ID
ROLE_1
VIEW
ROLE_1
ID
ROLE_2
HAS READ
PERMISSION ID
ROLE_2
READ
ROLE_2
ID
ROLE_3
HAS DELETE
PERMISSION ID
ROLE_3
DELETE
ROLE_3
How can i do that in symfony 我该如何在symfony中做到这一点
Use JMS http://jmsyst.com/bundles/JMSSecurityExtraBundle . 使用JMS http://jmsyst.com/bundles/JMSSecurityExtraBundle 。 Here is how using annotation:
这是使用注释的方法:
<?php
use JMS\SecurityExtraBundle\Annotation\Secure;
class YourClassName extends Controller
{
/**
* @Secure(roles="ROLE_1, ROLE_ANOTHER")
*/
public function viewAction() {
}
/**
* @Secure(roles="ROLE_2")
*/
public function editAction() {
}
//....
}
Or use Access Control List for advanced use case: http://symfony.com/doc/current/cookbook/security/acl.html 或将访问控制列表用于高级用例: http : //symfony.com/doc/current/cookbook/security/acl.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.