Merge branch 'feature/inspect-permission-11764'

This commit is contained in:
Thomas Gelf 2016-11-03 11:50:01 +01:00
commit f43481a13e
5 changed files with 24 additions and 5 deletions

View File

@ -8,6 +8,7 @@ class EndpointController extends ObjectController
{
public function init()
{
$this->assertPermission('director/inspect');
parent::init();
if ($this->object && $this->object->hasApiUser()) {
$params['endpoint'] = $this->object->object_name;

View File

@ -6,6 +6,12 @@ use Icinga\Module\Director\Web\Controller\ActionController;
class InspectController extends ActionController
{
public function init()
{
$this->assertPermission('director/inspect');
parent::init();
}
public function typesAction()
{
$api = $this->api();

View File

@ -3,6 +3,7 @@
$this->providePermission('director/api', $this->translate('Allow to access the director API'));
$this->providePermission('director/hosts/read', $this->translate('Allow to configure hosts'));
$this->providePermission('director/hosts/write', $this->translate('Allow to configure hosts'));
$this->providePermission('director/inspect', $this->translate('Allow to inspect objects through the Icinga 2 API'));
$this->providePermission('director/templates/read', $this->translate('Allow to see template details'));
$this->providePermission('director/templates/write', $this->translate('Allow to configure templates'));

View File

@ -6,6 +6,7 @@ use Exception;
use Icinga\Application\Config;
use Icinga\Module\Director\Db;
use Icinga\Module\Director\Objects\IcingaHost;
use Icinga\Module\Director\Util;
use Icinga\Module\Monitoring\Hook\HostActionsHook;
use Icinga\Module\Monitoring\Object\Host;
use Icinga\Web\Url;
@ -29,16 +30,21 @@ class HostActions extends HostActionsHook
}
if (IcingaHost::exists($host->host_name, $db)) {
return array(
$actions = array(
'Modify' => Url::fromPath(
'director/host/edit',
array('name' => $host->host_name)
),
'Inspect' => Url::fromPath(
'director/inspect/object',
array('type' => 'host', 'plural' => 'hosts', 'name' => $host->host_name)
)
);
if (Util::hasPermission('director/inspect')) {
$actions['Inspect'] = Url::fromPath(
'director/inspect/object',
array('type' => 'host', 'plural' => 'hosts', 'name' => $host->host_name)
);
}
return $actions;
} else {
return array();
}

View File

@ -6,6 +6,7 @@ use Exception;
use Icinga\Application\Config;
use Icinga\Module\Director\Db;
use Icinga\Module\Director\Objects\IcingaHost;
use Icinga\Module\Director\Util;
use Icinga\Module\Monitoring\Hook\ServiceActionsHook;
use Icinga\Module\Monitoring\Object\Service;
use Icinga\Web\Url;
@ -23,6 +24,10 @@ class ServiceActions extends ServiceActionsHook
protected function getThem(Service $service)
{
if (! Util::hasPermission('director/inspect')) {
return array();
}
$db = $this->db();
if (! $db) {
return array();