mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-25 23:04:51 +02:00
Security: Remove getPermissions and getRestrictions from the AdmissionLoader
These funtctions are superseded by getRestrictionsAndPermissions. refs #5647
This commit is contained in:
parent
bed11ebb60
commit
3e1583ca40
@ -86,74 +86,4 @@ class AdmissionLoader
|
|||||||
}
|
}
|
||||||
return array($permissions, $restrictions);
|
return array($permissions, $restrictions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get user permissions
|
|
||||||
*
|
|
||||||
* @param User $user
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getPermissions(User $user)
|
|
||||||
{
|
|
||||||
$permissions = array();
|
|
||||||
try {
|
|
||||||
$config = Config::app('permissions');
|
|
||||||
} catch (NotReadableError $e) {
|
|
||||||
Logger::error(
|
|
||||||
'Can\'t get permissions for user \'%s\'. An exception was thrown:',
|
|
||||||
$user->getUsername(),
|
|
||||||
$e
|
|
||||||
);
|
|
||||||
return $permissions;
|
|
||||||
}
|
|
||||||
$username = $user->getUsername();
|
|
||||||
$userGroups = $user->getGroups();
|
|
||||||
foreach ($config as $section) {
|
|
||||||
if (! empty($section->permissions)
|
|
||||||
&& $this->match($username, $userGroups, $section)
|
|
||||||
) {
|
|
||||||
$permissions = array_merge(
|
|
||||||
$permissions,
|
|
||||||
array_diff(String::trimSplit($section->permissions), $permissions)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $permissions;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get user restrictions
|
|
||||||
*
|
|
||||||
* @param User $user
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getRestrictions(User $user)
|
|
||||||
{
|
|
||||||
$restrictions = array();
|
|
||||||
try {
|
|
||||||
$config = Config::app('restrictions');
|
|
||||||
} catch (NotReadableError $e) {
|
|
||||||
Logger::error(
|
|
||||||
'Can\'t get restrictions for user \'%s\'. An exception was thrown:',
|
|
||||||
$user->getUsername(),
|
|
||||||
$e
|
|
||||||
);
|
|
||||||
return $restrictions;
|
|
||||||
}
|
|
||||||
$username = $user->getUsername();
|
|
||||||
$userGroups = $user->getGroups();
|
|
||||||
foreach ($config as $section) {
|
|
||||||
if (! empty($section->restriction)
|
|
||||||
&& $this->match($username, $userGroups, $section)
|
|
||||||
) {
|
|
||||||
$restrictions = array_merge(
|
|
||||||
$restrictions,
|
|
||||||
array_diff(String::trimSplit($section->restriction), $restrictions)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $restrictions;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user