mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-30 01:04:09 +02:00
Add wildcard support to the permission passed to User::can()
refs #8720
This commit is contained in:
parent
33112f6a18
commit
7f010102f6
@ -422,8 +422,16 @@ class User
|
|||||||
if (isset($this->permissions['*']) || isset($this->permissions[$permission])) {
|
if (isset($this->permissions['*']) || isset($this->permissions[$permission])) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// If the permission to check contains a wildcard, grant the permission if any permit related to the permission
|
||||||
|
// matches
|
||||||
|
$any = strpos($permission, '*');
|
||||||
foreach ($this->permissions as $permitted) {
|
foreach ($this->permissions as $permitted) {
|
||||||
$wildcard = strpos($permitted, '*');
|
if ($any !== false) {
|
||||||
|
$wildcard = $any;
|
||||||
|
} else {
|
||||||
|
// If the permit contains a wildcard, grant the permission if it's related to the permit
|
||||||
|
$wildcard = strpos($permitted, '*');
|
||||||
|
}
|
||||||
if ($wildcard !== false) {
|
if ($wildcard !== false) {
|
||||||
if (substr($permission, 0, $wildcard) === substr($permitted, 0, $wildcard)) {
|
if (substr($permission, 0, $wildcard) === substr($permitted, 0, $wildcard)) {
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user