Step 7: Adding role based ACL security
Note:
注意:
This bundle ships with support different security setups. You can also have a look at Adding Symfony2's built in ACL security.
本功能包支持不同的安全设置。您也可以查看添加Symfony2的内建ACL安全
CommentBundle also provides the ability to configure permissions based on the roles a specific user has. See the configuration example below for how to customise the default roles used for permissions.
CommentBundle也可以基于某个特定用户角色来配置权限。参见下面的配置示例,看看如何使用缺省的角色来自定义权限。
To configure Role based security override the Acl services:
要配置基于角色的安全需要覆盖ACL服务:
# app/config/config.yml
fos_comment:
acl: true
service:
acl:
thread: fos_comment.acl.thread.roles
comment: fos_comment.acl.comment.roles
vote: fos_comment.acl.vote.roles
manager:
thread: fos_comment.manager.thread.acl
comment: fos_comment.manager.comment.acl
vote: fos_comment.manager.vote.acl
To change the roles required for specific actions, modify the acl_roles
configuration key:
要为特定操作改变要求的角色,需要修改 acl_roles
配置项:
# app/config/config.yml
fos_comment:
acl_roles:
comment:
create: IS_AUTHENTICATED_ANONYMOUSLY
view: IS_AUTHENTICATED_ANONYMOUSLY
edit: ROLE_ADMIN
delete: ROLE_ADMIN
thread:
create: IS_AUTHENTICATED_ANONYMOUSLY
view: IS_AUTHENTICATED_ANONYMOUSLY
edit: ROLE_ADMIN
delete: ROLE_ADMIN
vote:
create: IS_AUTHENTICATED_ANONYMOUSLY
view: IS_AUTHENTICATED_ANONYMOUSLY
edit: ROLE_ADMIN
delete: ROLE_ADMIN
That is it!
Return to the index.
返回到指南索引页。
Ctrl+Enter 发布
发布
取消