Feature request : dashboard based on roles
Hello,
Is your feature request related to a problem? Please describe.
We are going to link our icingaweb2 to the microsoft AD. All the users are placed in a specific role. What we can't do with the current icingaweb2 is give a specific dashboard based on the role. Currently we only see that it is based on username (if i'm not wrong).
Question
Are there plans in the near future to make the dashboard also role-based?
Describe the solution you'd like
Due to the large number of users that we want to give access, we have taken a look at the code that it is not possible to solve the problem with few modifications.
We have modified the function listConfigFilesForUser so that it looks, if there is no user dashboard, for a dashboard with the role as folder name. And if there is no user dashboard or role dashboard, it will check that there is no default folder with a dasboard.ini
File : Icinga/Legacy/DashboardConfig.php
/**
* List all dashboard configuration files that match the given user
*
* @param User $user
*
* @return string[]
*/
public static function listConfigFilesForUser(User $user)
{
$files = array();
$dashboards = static::resolvePath('dashboards');
if ($handle = @opendir($dashboards)) {
while (false !== ($entry = readdir($handle))) {
if ($entry[0] === '.' || ! is_dir($dashboards . '/' . $entry)) {
continue;
}
if (strtolower($entry) === strtolower($user->getUsername())) {
$files[] = $dashboards . '/' . $entry . '/dashboard.ini';
}
}
closedir($handle);
}
if (empty($files)) {
$roles = $user->getRoles();
if (! empty($roles)) {
foreach($roles as $role) {
if ($handle = @opendir($dashboards)) {
while (false !== ($entry = readdir($handle))) {
if ($entry[0] === '.' || ! is_dir($dashboards . '/' . $entry)) {
continue;
}
if (strtolower($entry) === strtolower($role->getName())) {
$files[] = $dashboards . '/' . $entry . '/dashboard.ini';
}
}
closedir($handle);
}
}
}
}
if (empty($files)) {
if ($handle = @opendir($dashboards)) {
while (false !== ($entry = readdir($handle))) {
if ($entry[0] === '.' || ! is_dir($dashboards . '/' . $entry)) {
continue;
}
if (strtolower($entry) === 'default') {
$files[] = $dashboards . '/default/dashboard.ini';
}
}
closedir($handle);
}
}
return $files;
}
Perhaps this is something that might be of interest to those who work with many users and do you also want to implement this.
regards, Geert
See here my first request :
#5074