承接 kinulab/efficient-vote-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kinulab/efficient-vote-bundle

Composer 安装命令:

composer require kinulab/efficient-vote-bundle

包简介

Provide a system to enhance performances of the security by voters

README 文档

README

With Symfony you can install access management either with ACLs or with voters. ACLs are hard to implements and voters have performances issues. This bundle provides a way to enjoy the simplicity of voters without the drawback of performances.

Backgroup

The performance issue of voters comes from the AccessDecisionManager service. His role is to ask every voter to know if the current user is allowed to perform a given action (e.g. ROLE_SUPER_ADMIN). The problem is that this service is not aware that most of the voters will abstain as they don't support the attribute.

So, if your application has 10 voters and your template uses 10 times the is_granted() function, it makes 100 calls. If your application grows, this will become a bottleneck.

To solve that, this bundle overwrites the default AccessDecisionManager service. With the new service, you can register your voters and specify which attributes are supported. The access decision manager will so not call your voter if he's not competent for the attribute.

Installation

composer require kinulab/efficient-vote-bundle

Then add in you app/config/AppKernel.php :

    public function registerBundles()
    {
        $bundles = [
            // [...]
            new Kinulab\EfficientVoteBundle\KinulabEfficientVoteBundle(),
        ];

Usage

The new access decision manager will assume that you organize your voter by types and by domains.

Your must then name your roles with this forms:

ROLE _ HOUSE _ OPEN_DOOR
|__|   |___|   |_______|
type   domain  attribute

Your voters class remain exaclty like the standards symfony voters. The only difference is on the registration of your voter service.

With a standard vorter, your service is registered like that:

# app/config/services.yml
services:
    app.host_voter:
        class: AppBundle\Security\hostVoter
        # small performance boost
        public: false
        tags:
            - { name: security.voter }

With this bundle you should now register your service like that :

# app/config/services.yml
services:
    app.host_voter:
        class: AppBundle\Security\hostVoter
        # small performance boost
        public: false
        tags:
            # big performance boost
            - { name: security.efficient_voter, type: ROLE, domain: HOUSE }

With this configuration, the voter above, will be called only for the ROLE_HOUSE_* attributes.

Note

The new access decision manager remains compatible with the original. So if you have some voters that are registered the old way, they will still work as expected (but called tons of time).

统计信息

  • 总下载量: 1.68k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-11-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固