FOSCommentBundle功能包:基于ACL安全添加角色

  • 原文出处:7-adding_role_based_acl_security.md

  • 原文作者:FriendsOfSymfony

  • 授权许可:创作共用协议

  • 翻译人员:FireHare

  • 校对人员:

  • 适用版本:FOSCommentBundle 2.0.5

  • 文章状态:草译阶段

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.

返回到指南索引页。


你可能感兴趣的:(Bundle,symfony2,功能包,基于ACL安全添加角色)