From 7213379cacb0c10e6d31d8761c1bd023829806aa Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 2 Jun 2015 11:59:04 +0200 Subject: [PATCH] AuthBackendController: Add final indexAction Required to automatically redirect to the first permitted list action. refs #8826 --- application/controllers/ConfigController.php | 2 +- application/controllers/GroupController.php | 8 -------- application/controllers/UserController.php | 8 -------- .../Web/Controller/AuthBackendController.php | 17 +++++++++++++++++ 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index 1837d3a89..9d55910e9 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -84,7 +84,7 @@ class ConfigController extends Controller public function indexAction() { if ($this->firstAllowedAction === null) { - throw new SecurityException($this->translate('No permission for configuration')); + throw new SecurityException($this->translate('No permission for application configuration')); } $action = $this->getTabs()->get($this->firstAllowedAction); if (substr($action->getUrl()->getPath(), 0, 7) === 'config/') { diff --git a/application/controllers/GroupController.php b/application/controllers/GroupController.php index fe8dd58f8..70954aaf1 100644 --- a/application/controllers/GroupController.php +++ b/application/controllers/GroupController.php @@ -17,14 +17,6 @@ use Icinga\Web\Widget; class GroupController extends AuthBackendController { - /** - * Redirect to this controller's list action - */ - public function indexAction() - { - $this->redirectNow('group/list'); - } - /** * List all user groups of a single backend */ diff --git a/application/controllers/UserController.php b/application/controllers/UserController.php index 30e0bc100..c71fe9696 100644 --- a/application/controllers/UserController.php +++ b/application/controllers/UserController.php @@ -17,14 +17,6 @@ use Icinga\Web\Widget; class UserController extends AuthBackendController { - /** - * Redirect to this controller's list action - */ - public function indexAction() - { - $this->redirectNow('user/list'); - } - /** * List all users of a single backend */ diff --git a/library/Icinga/Web/Controller/AuthBackendController.php b/library/Icinga/Web/Controller/AuthBackendController.php index 45b512c8a..43ed78fd7 100644 --- a/library/Icinga/Web/Controller/AuthBackendController.php +++ b/library/Icinga/Web/Controller/AuthBackendController.php @@ -9,6 +9,7 @@ use Icinga\Authentication\User\UserBackend; use Icinga\Authentication\User\UserBackendInterface; use Icinga\Authentication\UserGroup\UserGroupBackend; use Icinga\Authentication\UserGroup\UserGroupBackendInterface; +use Icinga\Security\SecurityException; use Icinga\Web\Controller; /** @@ -16,6 +17,22 @@ use Icinga\Web\Controller; */ class AuthBackendController extends Controller { + /** + * Redirect to the first permitted list action + */ + final public function indexAction() + { + if ($this->hasPermission('config/authentication/users/show')) { + $this->redirectNow('user/list'); + } elseif ($this->hasPermission('config/authentication/groups/show')) { + $this->redirectNow('group/list'); + } elseif ($this->hasPermission('config/authentication/roles/show')) { + $this->redirectNow('role/list'); + } else { + throw new SecurityException($this->translate('No permission for authentication configuration')); + } + } + /** * Return all user backends implementing the given interface *