PHP-Casbin 是一个用PHP语言打造的轻量级开源访问控制框架。PHP-Casbin采用了元模型的设计思想,支持多种经典的访问控制方案,如基于角色的访问控制RBAC、基于属性的访问控制ABAC等。
Laraval-Casbin 是一个专为Laravel定制的Casbin的扩展包。
安装composer require casbin/laravel-adapter发布资源php artisan vendor:publish部署数据库php artisan migrate快速开始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 (Casbin::enforce($sub, $obj, $act) === true) { // permit alice to read data1} else { // deny the request, show an error}更多Casbin官方网站:https://casbin.org
Laraval-Casbin的更多用法: https://github.com/php-casbin/laravel-casbin
联系作者有问题请提交Issues: https://github.com/php-casbin/laravel-casbin/issues
评论