GithubHelp home page GithubHelp logo

laiyongqin / think-casbin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from php-casbin/think-casbin

0.0 2.0 0.0 12 KB

专为ThinkPHP5.1定制的Casbin的扩展包,Casbin是一个功能强大,高效的开源访问控制库。

License: Apache License 2.0

PHP 100.00%

think-casbin's Introduction

ThinkPHP-Casbin

一个专为ThinkPHP5.1定制的Casbin的扩展包( https://github.com/php-casbin/think-casbin )。

安装

在你的thinkphp项目里,通过composer安装这个扩展

composer require casbin/think-adapter

发布资源:

php think casbin:publish

这将自动创建model配置文件config/casbin-basic-model.conf,和Casbin的配置文件config/casbin.php

数据迁移:

执行前,请确保数据库连接信息配置正确,如需修改数据库连接信息或表名,可以修改config/casbin.php里的配置

php think casbin:migrate

这将会自动创建Casbin的策略表casbin_rule

用法

use Casbin;

$sub = 'alice'; // the user that wants to access a resource.
$obj = 'data1'; // the resource that is going to be accessed.
$act = 'read'; // the operation that the user performs on the resource.

if (true === Casbin::enforce($sub, $obj, $act)) {
    // permit alice to read data1x
    echo 'permit alice to read data1';
} else {
    // deny the request, show an error
}

自定义配置

config/casbin-basic-model.conf为Casbin的model文件

config/casbin.php为Casbin的adapter、db配置信息

关于Casbin

Casbin官网文档 (https://casbin.org )查看更多用法。

think-casbin's People

Contributors

leeqvip avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.