Skip to content

Commit

Permalink
Merge 24640ec into 2cd00bd
Browse files Browse the repository at this point in the history
  • Loading branch information
zhhzone committed Jan 14, 2021
2 parents 2cd00bd + 24640ec commit f382c1c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/Enforcer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Casbin;

use Casbin\Exceptions\CasbinException;

use Casbin\Util\Util;
/**
* Enforcer = ManagementEnforcer + RBAC API.
*
Expand Down Expand Up @@ -330,22 +330,24 @@ public function getImplicitPermissionsForUser(string $user, string ...$domain):
*/
public function getImplicitUsersForPermission(string ...$permission): array
{
$subjects = $this->getAllSubjects();
$roles = $this->getAllRoles();

$users = array_diff($subjects, $roles);

$pSubjects = $this->getAllSubjects();
$gInherit = $this->model->getValuesForFieldInPolicy("g","g", 0);
$gSubjects = $this->model->getValuesForFieldInPolicy("g","g", 1);

$users = array_merge($pSubjects, $gInherit);
$users = array_diff($users, $gSubjects);

Util::arrayRemoveDuplicates($users);
$res = [];
foreach ($users as $user) {
$req = $permission;
array_unshift($req, $user);
$allowed = $this->enforce(...$req);

if ($allowed) {
$res[] = $user;
}
}

}
return $res;
}

Expand Down

0 comments on commit f382c1c

Please sign in to comment.