PHP-Casbin 是一個用 PHP 語言打造的輕量級開源訪問控制框架( https://github.com/php-casbin... ),目前在 GitHub 開源。PHP-Casbin 採用了元模型的設計思想,支持多種經典的訪問控制方案,如基於角色的訪問控制 RBAC、基於屬性的訪問控制 ABAC 等。
Laraval-Casbin 是一個專爲Laravel定製的Casbin
的擴展包( https://github.com/php-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 data1x
} else {
// deny the request, show an error
}
更多
Casbin官方網站:https://casbin.org
Laraval-Casbin的更多用法: https://github.com/php-casbin...
聯繫作者
有問題請提交 Issues: https://github.com/php-casbin...
或者加入 QQ 羣:546057381( Casbin 訪問控制討論羣)