slimphp-api/slim-acl 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

slimphp-api/slim-acl

最新稳定版本:1.0.0

Composer 安装命令:

composer require slimphp-api/slim-acl

包简介

A middleware module for Slim3 to provide ACL using ZF2's Zend\Permissions\Acl

README 文档

README

ACL middleware for slim, using Zend\Permissions\Acl

Coverage Status Code Climate Build Status

Configuration passed into the middleware constructor should look like:

[
    'default_role' => 'guest',
    'roles' => [
        'guest' => [],
        'user'  => ['guest'],
        'admin' => ['user']
    ],
    /*
     * just a list of generic resources for manual checking
     * specified here so can be used in the code if needs be
     */
     'resources' => [
         'banana' => null,
         'orange' => null,
     ],
    // where we specify the guarding!
    'guards' => [
        /*
         * list of resource to roles to permissions
         * optional
         * if included all resources default to deny unless specified.
         */
        'resources' => [
            ['banana', ['user'], ['peel']],
            ['banana', ['admin']],
            ['orange', ['guest'], ['peel']],
            ['orange', ['user'], ['eat']],
        ],
        /*
         * list of literal routes for guarding.
         * optional
         * if included all routes default to deny unless specified.
         * Similar format to resource 'resource' route, roles, 'permission' action
         * ['route', ['roles'], ['methods',' methods1']]
         */
        'routes' => [
            ['/home',       ['user'],  ['get']],
            ['/user',       ['admin'], ['get', 'post']], // $app->map(['POST', 'PUT'], '/user', ...);
            ['/user/{id}',  ['user'],  ['get']], // $app->map(['GET'], '/user/{id}', ...);
        ],
        /*
         * list of callables to resolve against
         * optional
         * if included all callables default to deny unless specified.
         * 'permission' section is combined into the callable section
         * ['callable', ['roles']]
         */
        'callables' => [
            ['App\Controller\UserController',           ['user']], // $app->map(['GET'], '/user',      'App\Controller\UserController'); class with __invoke
            ['App\Controller\UserController:getAction', ['user']], // $app->map(['GET'], '/user/{id}', 'App\Controller\UserController:getAction'); class and method
        ]
    ]
]

Important: The route should be determined before the app middlewares are being fired by:

$app = new Slim\App([
    'settings'  => [
        'determineRouteBeforeAppMiddleware' => true,
    ]
]);

统计信息

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

GitHub 信息

  • Stars: 17
  • Watchers: 4
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-10-31