hyperf-casbin
hyperf-casbin copied to clipboard
适配 Hyperf 的开源访问控制框架Casbin
先执行 Enforcer::addPermissionForUser 再执行Enforcer::deletePermissionForUser删除同样的权限,但是再次调用添加权限方法失败,追代码追到 InternalEnforcer类中addPolicyInternal方法中的$this->model->hasPolicy($sec, $ptype, $rule)判断返回true,前面删除了权限这里应该返回false啊,所以设置了watcher为true也没用,但是在hyperf启动命令行中看到执行deletePermissionForUser方法,有Event Donjan\Casbin\Event\PolicyChanged handled by Donjan\Casbin\Listener\OnPolicyChangedListener listener.策略更新监听触发了。但是hasPolicy方法和getPermissionsForUser方法得出来的结果还是未更新前的。所以请问这个watcher在常驻进程中没有效果
Enforcer::deleteRolesForUser($user_id); Enforcer::AddNamedPolicies('g', $rows);
完善注解
hyperf环境下 A用户在浏览器a对B用户修改角色权限 Enforcer::addRoleForUser("user{$userId}", "role{$roleId}"); Enforcer::addRoleForUser("user{$userId}", "role{$roleId}", '*'); Enforcer::deleteRoleForUser("user{$userId}", "role{$roleId}"); Enforcer::deleteRoleForUser("user{$userId}", "role{$roleId}", '*'); A用户修改B用户是,通过Enforcer::getRolesForUser查询的角色信息 ``` string(54) "这是修改前前前前前前的权限信息 == 27381" array(0) { } string(54) "这是修改后后后后后后的权限信息 == 27381" array(1) { [0]=> string(6) "role22"...
DatabaseAdapter 344 行 Filter 类未引入。
$serverConfig['type'] 没有做判空处理
//model ** [request_definition] r = sub, obj, act [policy_definition] p = sub, obj, act [role_definition] g = _, _ [policy_effect] e = some(where (p.eft == allow)) [matchers] m = g(r.sub,...
 以下是打印$serverConfig 