Skip to content

Medoo Adapter for PHP-Casbin, Casbin is a powerful and efficient open-source access control library.

License

Notifications You must be signed in to change notification settings

Dobmod/medoo-adapter

This branch is 1 commit behind php-casbin/medoo-adapter:master.

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Medoo Adapter for Casbin

Build Status Coverage Status Latest Stable Version Total Downloads License

Medoo Adapter for PHP-Casbin, Casbin is a powerful and efficient open-source access control library.

Medoo is a lightweight PHP Database Framework to Accelerate Development, supports all SQL databases, including MySQL, MSSQL, SQLite, MariaDB, PostgreSQL, Sybase, Oracle and more.

Installation

Via Composer.

composer require casbin/medoo-adapter

Usage

require_once './vendor/autoload.php';

use Casbin\Enforcer;
use CasbinAdapter\Medoo\Adapter as DatabaseAdapter;

$config = [
    'database_type' => 'mysql',
    'server' => '127.0.0.1',
    'database_name' => 'test',
    'username' => 'root',
    'password' => '',
    'port' => '3306',
];

$adapter = DatabaseAdapter::newAdapter($config);

$e = new Enforcer('path/to/model.conf', $adapter);

$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 ($e->enforce($sub, $obj, $act) === true) {
    // permit alice to read data1
} else {
    // deny the request, show an error
}

Getting Help

License

This project is licensed under the Apache 2.0 license.

About

Medoo Adapter for PHP-Casbin, Casbin is a powerful and efficient open-source access control library.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%