Awesome Open Source
Awesome Open Source

webman casbin plugin

Latest Stable Version Total Downloads Daily Downloads Latest Unstable Version License PHP Version Require

An authorization library that supports access control models like ACL, RBAC, ABAC for webman plugin

composer require -W casbin/webman-permission

1.

config/container.php

$builder = new \DI\ContainerBuilder();
$builder->addDefinitions(config('dependence', []));
$builder->useAutowiring(true);
return $builder->build();

2.

ThinkORM laravel illuminate/databasehttps://www.workerman.net/doc/webman/db/tutorial.html

(1)

ThinkORM

  • thinkorm.php

laravel

  • database.php
  • permission.php adapterlaravel

(2) casbin_rule

CREATE TABLE `casbin_rule` (
	`id` BIGINT ( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT,
	`ptype` VARCHAR ( 128 ) NOT NULL DEFAULT '',
	`v0` VARCHAR ( 128 ) NOT NULL DEFAULT '',
	`v1` VARCHAR ( 128 ) NOT NULL DEFAULT '',
	`v2` VARCHAR ( 128 ) NOT NULL DEFAULT '',
	`v3` VARCHAR ( 128 ) NOT NULL DEFAULT '',
	`v4` VARCHAR ( 128 ) NOT NULL DEFAULT '',
	`v5` VARCHAR ( 128 ) NOT NULL DEFAULT '',
	PRIMARY KEY ( `id` ) USING BTREE,
	KEY `idx_ptype` ( `ptype` ) USING BTREE,
	KEY `idx_v0` ( `v0` ) USING BTREE,
	KEY `idx_v1` ( `v1` ) USING BTREE,
	KEY `idx_v2` ( `v2` ) USING BTREE,
	KEY `idx_v3` ( `v3` ) USING BTREE,
	KEY `idx_v4` ( `v4` ) USING BTREE,
    KEY `idx_v5` ( `v5` ) USING BTREE 
) ENGINE = INNODB CHARSET = utf8mb4 COMMENT = '';

(3) config/redis

webman

php start.php restart
php start.php restart -d

:

use Casbin\WebmanPermission\Permission;

// adds permissions to a user
Permission::addPermissionForUser('eve', 'articles', 'read');
// adds a role for a user.
Permission::addRoleForUser('eve', 'writer');
// adds permissions to a rule
Permission::addPolicy('writer', 'articles','edit');

:

if (Permission::enforce("eve", "articles", "edit")) {
    echo '';
} else {
    echo '';
}

API Casbin API

Casbin

https://github.com/PHP-DI/PHP-DI

1DIcomposer remove php-di/php-di

2Casbin\WebmanPermission\Permission

if (is_null(static::$_manager)) {
    static::$_manager = new Enforcer($model, Container::get($config['adapter']),false);
}
if (is_null(static::$_manager)) {
    if ($config['adapter'] == DatabaseAdapter::class) {
        $_model = new RuleModel();
    } elseif ($config['adapter'] == LaravelDatabaseAdapter::class) {
        $_model = new LaravelRuleModel();
    }
    static::$_manager = new Enforcer($model,  new $config['adapter']($_model), false);
}

https://www.workerman.net/doc/webman/di.html

Alternatives To Webman Permission
Select To Compare


Alternative Project Comparisons
Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Php (285,849
Authentication (26,846
Permission (11,613
Authorization (5,850
Acl (2,435
Rbac (1,373
Thinkphp (810
Casbin (286
Workerman (176
Webman (16
Casbin Adapter (13