support des roles dans CAS

This commit is contained in:
Jephté Clain 2024-04-29 11:02:44 +04:00
parent 5991fb4c2e
commit 2a26b7db8d
1 changed files with 6 additions and 7 deletions

View File

@ -28,21 +28,20 @@ class CasUserManager extends SimpleUserManager {
$authzs = explode(",", $authzs);
$appcode = $this->appcode;
$groups = [];
$role = null;
$perms = [];
foreach ($authzs as $authz) {
if ($authz == "*:*") {
$perms[] = "*";
} elseif ($authz == "$appcode:*") {
$perms[] = "*";
} elseif (str::del_prefix($authz, "$appcode:")) {
if (str::del_prefix($authz, "@")) {
$groups[] = $authz;
} else {
$perms[] = $authz;
}
if ($authz == "*") $perms[] = "*";
elseif (str::del_prefix($authz, "@")) $groups[] = $authz;
elseif (str::del_prefix($authz, "*")) $role = $authz;
else $perms[] = $authz;
}
}
A::merge($user["groups"], $groups);
if ($role !== null) $user["role"] = $role;
A::merge($user["perms"], $perms);
}
}