Add wildcard support to the permission passed to User::can()

refs 
This commit is contained in:
Eric Lippmann 2015-03-12 15:27:44 +01:00
parent 33112f6a18
commit 7f010102f6
1 changed files with 9 additions and 1 deletions
library/Icinga

View File

@ -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;