futuretek/yii2-rbac 问题修复 & 功能扩展

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

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

futuretek/yii2-rbac

最新稳定版本:2.1.0

Composer 安装命令:

composer require futuretek/yii2-rbac

包简介

RBAC

README 文档

README

Requirements

  • For RBAC to function correctly Yii cache component must be configured.

Configuration

Place config into @app/rbac/config.php

<?php
return [
    'roles' => [
        ['name' => 'admin', 'description' => 'Unrestricted access including developer tools.', 'system' => true, 'data' => null],
        .
        .
    ],
    'permissions' => [
        'operator' => [
            'CallCenter' => 'all',
            'Order' => ['Index', 'View'],
            .
            .
        ],
        .
        .
    ],
    'specialPermissions' => [
        [
            'category' => 'main',
            'action' => 'login',
            'name' => 'MainLogin',
            'description' => 'Allow to login the user',
        ],
        .
        .
    ],
];

Console actions

  • yii rbac/init - Initialize RBAC database, builds permissions and default roles.
  • yii rbac/export - Export permissions to file.
  • yii rbac/import - Import permissions from file based on application language.

Usage

Permissions Init

ATTENTION This command should be used only in development process.

Permission names are created from controller and action name.

Init command will create permissions and roles. Also admin user is created and granted all permissions.

When in developer mode, this command enables you to clear original permissions. In other environments only permission update is possible.

Permissions Export

Permissions should be exported and committed to versioning system when releasing the application.

Export is done using the command:

yii rbac/export

These files are created in @app/rbac/ during export:

  • auth-assignment
  • auth-item
  • auth-item-child
  • auth-rule

Permissions Import

Permission import should be executed when new release is deployed on target instance. Import will restore exported permissions from files to database.

Import is done using command:

yii rbac/import

Import expect that files noted above are present in @app/rbac/

Note: file auth-item should be renamed to current language to import to work properly - see next chapter.

Permission translation

Authentication items (permission and role names) contained in file auth-item can/should be translated.

When importing permissions, the script is looking for file corresponding to selected language (Yii::$app->language). File format is:

auth-item.<iso-code>

where <iso-code> is two digit language ISO code. For example auth-item.en.

If application language is set using locale (eg. en-US), only first part (language code) is used.

Usage in application

For operations with permissions (create, update, delete) use AuthItem model (instead of Yii:$app->authManager).

Permission checking method has not changed - Yii::$app->user->can().

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2021-11-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固