Add wildcard support to the permission passed to User::can()
refs #8720
This commit is contained in:
parent
33112f6a18
commit
7f010102f6
library/Icinga
|
@ -422,8 +422,16 @@ class User
|
|||
if (isset($this->permissions['*']) || isset($this->permissions[$permission])) {
|
||||
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) {
|
||||
$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 (substr($permission, 0, $wildcard) === substr($permitted, 0, $wildcard)) {
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue