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