Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/php-casbin/medoo-adapter
Medoo Adapter for PHP-Casbin, Casbin is a powerful and efficient open-source access control library.
https://github.com/php-casbin/medoo-adapter
abac access-control acl casbin medoo permissions rbac restful security
Last synced: 2 months ago
JSON representation
Medoo Adapter for PHP-Casbin, Casbin is a powerful and efficient open-source access control library.
- Host: GitHub
- URL: https://github.com/php-casbin/medoo-adapter
- Owner: php-casbin
- License: apache-2.0
- Created: 2019-09-09T09:11:04.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-29T16:16:18.000Z (3 months ago)
- Last Synced: 2024-10-29T20:52:48.299Z (3 months ago)
- Topics: abac, access-control, acl, casbin, medoo, permissions, rbac, restful, security
- Language: PHP
- Homepage: https://github.com/php-casbin/php-casbin
- Size: 24.4 KB
- Stars: 4
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Medoo Adapter for Casbin
[![Build Status](https://github.com/php-casbin/medoo-adapter/actions/workflows/build.yml/badge.svg)](https://github.com/php-casbin/medoo-adapter/actions/workflows/build.yml)
[![Coverage Status](https://coveralls.io/repos/github/php-casbin/medoo-adapter/badge.svg)](https://coveralls.io/github/php-casbin/medoo-adapter)
[![Latest Stable Version](https://poser.pugx.org/casbin/medoo-adapter/v/stable)](https://packagist.org/packages/casbin/medoo-adapter)
[![Total Downloads](https://poser.pugx.org/casbin/medoo-adapter/downloads)](https://packagist.org/packages/casbin/medoo-adapter)
[![License](https://poser.pugx.org/casbin/medoo-adapter/license)](https://packagist.org/packages/casbin/medoo-adapter)[Medoo](https://github.com/catfan/Medoo) Adapter for [PHP-Casbin](https://github.com/php-casbin/php-casbin), [Casbin](https://casbin.org/) 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](https://getcomposer.org/).
```
composer require casbin/medoo-adapter
```### Usage
```php
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
- [php-casbin](https://github.com/php-casbin/php-casbin)
### License
This project is licensed under the [Apache 2.0 license](LICENSE).