Download the PHP package hainuo/think-rbac without Composer

On this page you can find all versions of the php package hainuo/think-rbac. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package think-rbac

think-rbac

版权及用途说明

基于 zouxiang0639/thinkcms-auth 制作,供个人或公司使用,其他人员请谨慎使用,不维护他人需求或bug

v0.0.1 使用说明

  1. 执行命令 composer require hainuo/think-rbac 安装类库
  2. 首先安装数据库 没有做自动安装功能,后续看业务需求
  3. 在管理模块例如admin下的控制器中新增一个控制器,控制器的名字必须为Auth

    1. 文件结构类似下面

    2. Auth.php内容如下

      config.php 内容如下

  4. 管理访问 基于上述admin的访问路径

    ps: 注意这里跟 数据库中的配置是有区别的数据库中 配置的模块名可能是index所以 需要你在合适的时候自行更改一下数据库中的内容

    1. 直接按照4中的地址进行访问的时候会报错 原因是 无法获取到用户信息 所以我们需要在 Auth.php 中定义一个超级用户 信息。我们可以在Autho.php 增加一个初始化方法来解决这个问题。代码如下

    2. 可以看到下图了
    3. 关于权限校验 可以在基类控制器中增加以下方法
  5. 其他的参照原版 唯一需要做的就是命名空间的变化

v0.0.1 版本 变更说明

  1. 目录优化 所有有效文件目录存放在src目录下
  2. 更新明明空间 thinkcms为think 使之更具有通用性
  3. 提交新的packgist 以被公司他人使用,同时可以供网友参考使用

以下是原版的说明

thinkphp5 权限认证 RBAC 加 行为日志

这个插件主要有一整套RBAC 行为日志 视图 只需要 composer安装即可和你的系统融为一体

安装

> composer require zouxiang0639/thinkcms-auth

v1.1更新

v1.1.1新加入方法

is_login()                              判断是否登录
login($uid 用户ID,$nickname 用户昵称)    用户登录
logout()                               用户退出
checkPath($path 路由,$param 参数)       检查路由是否有权限

配置 v1.1

'thinkcms' =>[
        'style_directory' => '/static/admin/',
        'session_prefix'  => 'abc_',
  ]

可以不配置 配置以后Js css文件需要放到配置的目录里

手动加入日志 v1.1

    $auth = new Auth();
    $auth->admin = $list['user_name'];
    $auth->createLog('管理员<spen style=\'color: #1dd2af;\'>[ {name} ]</spen>偷偷的进入后台了,','后台登录');

视图调用

     public function _empty($name)
        {
            $auth =  new \thinkcms\auth\Auth();
            $auth = $auth->autoload($name);
            if($auth){
                if(isset($auth['code'])){
                    return json($auth);
                }elseif(isset($auth['file'])){
                    return $auth['file'];
                }
                $this->view->engine->layout(false);
                return $this->fetch($auth[0],$auth[1]);
            }
            return abort(404,'页面不存在');
        }

在模块中创建一个Auth控制器,把_empty方法复制上去,这样就可以访问以下视图

权限认证

     public function __construct()
        {
            parent::__construct();
            $auth                   = new Auth();
            $auth->noNeedCheckRules = ['index/index/index','index/index/home'];
            $auth->log              = true;                 // v1.1版本  日志开关默认true
            $user                   = $auth::is_login();

            if($user){//用户登录状态
                $this->uid = $user['uid'];
                if(!$auth->auth()){
                    return $this->error("你没有权限访问!");
                }
            }else{
                return $this->error("您还没有登录!",url("publics/login"));
            }
        }

这里在公共控制器上加入验证即可

管理员独立权限

 url('auth/adminAuthorize',['id' => '用户ID','name'=>'用户昵称'])

授权菜单

 Auth::menuCheck();

这个方法返回授权及非隐藏的所有菜单,这样我们后台的菜单就可以根据管理员的权限来来展示授权的目录

mysql文件

tp_action_log.sql
tp_auth_access.sql
tp_auth_role.sql
tp_auth_role_user.sql
tp_auth_rule.sql
tp_menu.sql

案例下载(http://www.thinkphp.cn/extend/875.html)


All versions of think-rbac with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package hainuo/think-rbac contains the following files

Loading the files please wait ....