All Projects → php-casbin → laravel-casbin

php-casbin / laravel-casbin

Licence: Apache-2.0 license
This repository has moved to https://github.com/php-casbin/laravel-authz

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to laravel-casbin

sqlx-adapter
Asynchronous casbin adapter for mysql, postgres, sqlite based on sqlx-rs
Stars: ✭ 27 (-35.71%)
Mutual labels:  adapter, acl, permission, rbac, casbin
casbin-ex
An authorization library that supports access control models like ACL, RBAC, ABAC in Elixir
Stars: ✭ 37 (-11.9%)
Mutual labels:  acl, permission, rbac, casbin
Jcasbin
An authorization library that supports access control models like ACL, RBAC, ABAC in Java
Stars: ✭ 1,335 (+3078.57%)
Mutual labels:  acl, permission, rbac, casbin
actix-casbin-auth
Casbin Actix-web access control middleware
Stars: ✭ 40 (-4.76%)
Mutual labels:  acl, permission, rbac, casbin
Think Casbin
专为ThinkPHP定制的Casbin的扩展包,Casbin是一个功能强大,高效的开源访问控制库。
Stars: ✭ 138 (+228.57%)
Mutual labels:  acl, permission, rbac, casbin
Casbin Cpp
An authorization library that supports access control models like ACL, RBAC, ABAC in C/C++
Stars: ✭ 113 (+169.05%)
Mutual labels:  acl, permission, rbac, casbin
Casbin
An authorization library that supports access control models like ACL, RBAC, ABAC in Golang
Stars: ✭ 10,872 (+25785.71%)
Mutual labels:  acl, permission, rbac, casbin
Node Casbin
An authorization library that supports access control models like ACL, RBAC, ABAC in Node.js and Browser
Stars: ✭ 1,757 (+4083.33%)
Mutual labels:  acl, permission, rbac, casbin
Casbin.net
An authorization library that supports access control models like ACL, RBAC, ABAC in .NET (C#)
Stars: ✭ 535 (+1173.81%)
Mutual labels:  acl, permission, rbac, casbin
Pycasbin
An authorization library that supports access control models like ACL, RBAC, ABAC in Python
Stars: ✭ 625 (+1388.1%)
Mutual labels:  acl, permission, rbac, casbin
sequelize-adapter
Sequelize adapter for Casbin
Stars: ✭ 51 (+21.43%)
Mutual labels:  adapter, acl, rbac, casbin
Casbin Rs
An authorization library that supports access control models like ACL, RBAC, ABAC in Rust.
Stars: ✭ 375 (+792.86%)
Mutual labels:  acl, permission, rbac, casbin
lua-casbin
An authorization library that supports access control models like ACL, RBAC, ABAC in Lua (OpenResty)
Stars: ✭ 43 (+2.38%)
Mutual labels:  acl, permission, rbac, casbin
Gorm Adapter
Gorm adapter for Casbin
Stars: ✭ 373 (+788.1%)
Mutual labels:  adapter, acl, rbac, casbin
dart-casbin
An authorization library that supports access control models like ACL, RBAC, ABAC in Dart/Flutter
Stars: ✭ 30 (-28.57%)
Mutual labels:  acl, rbac, casbin
Negroni Authz
negroni-authz is an authorization middleware for Negroni
Stars: ✭ 152 (+261.9%)
Mutual labels:  acl, rbac, casbin
Think Authz
An authorization library that supports access control models like ACL, RBAC, ABAC in ThinkPHP 6.0 .
Stars: ✭ 155 (+269.05%)
Mutual labels:  acl, rbac, casbin
Openstack Policy Editor
A Casbin Policy Editor for OpenStack
Stars: ✭ 28 (-33.33%)
Mutual labels:  acl, rbac, casbin
Casbin Server
Casbin as a Service (CaaS)
Stars: ✭ 171 (+307.14%)
Mutual labels:  acl, rbac, casbin
Caddy Authz
Caddy-authz is a middleware for Caddy that blocks or allows requests based on access control policies.
Stars: ✭ 221 (+426.19%)
Mutual labels:  acl, rbac, casbin

Laravel-Casbin

Build Status Coverage Status Latest Stable Version Total Downloads License

Use Casbin in Laravel.

It is worth mentioning that we now recommend laravel-authz.

Installation

Require this package in the composer.json of your Laravel project. This will download the package.

composer require casbin/laravel-adapter

The CasbinAdapter\Laravel\CasbinServiceProvider is auto-discovered and registered by default, but if you want to register it yourself:

Add the ServiceProvider in config/app.php

'providers' => [
    /*
     * Package Service Providers...
     */
    CasbinAdapter\Laravel\CasbinServiceProvider::class,
]

The Casbin facade is also auto-discovered, but if you want to add it manually:

Add the Facade in config/app.php

'aliases' => [
    // ...
    'Casbin' => CasbinAdapter\Laravel\Facades\Casbin::class,
]

To publish the config, run the vendor publish command:

php artisan vendor:publish

This will create a new model config file named config/casbin-basic-model.conf and a new casbin config file named config/casbin.php.

To migrate the migrations, run the migrate command:

php artisan migrate

This will create a new table named casbin_rule

Usage

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
}

Define your own model.conf

You can modify the config file named config/casbin-basic-model.conf

Learning Casbin

You can find the full documentation of Casbin on the website.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].