diff --git a/application/forms/Command/Instance/ToggleInstanceFeaturesForm.php b/application/forms/Command/Instance/ToggleInstanceFeaturesForm.php index b28dbd59e..58136730b 100644 --- a/application/forms/Command/Instance/ToggleInstanceFeaturesForm.php +++ b/application/forms/Command/Instance/ToggleInstanceFeaturesForm.php @@ -41,7 +41,7 @@ public function __construct($featureStatus) protected function assembleElements() { - $disabled = ! $this->getAuth()->hasPermission('monitoring/command/feature/instance'); + $disabled = ! $this->getAuth()->hasPermission('icingadb/command/feature/instance'); $decorator = new IcingaFormDecorator(); foreach ($this->features as $feature => $label) { diff --git a/application/forms/Command/Object/AcknowledgeProblemForm.php b/application/forms/Command/Object/AcknowledgeProblemForm.php index d97bee3cb..1e4bfb665 100644 --- a/application/forms/Command/Object/AcknowledgeProblemForm.php +++ b/application/forms/Command/Object/AcknowledgeProblemForm.php @@ -141,7 +141,7 @@ protected function assembleSubmitButton() protected function getCommand(Model $object) { - if (! $this->isGrantedOn('monitoring/command/acknowledge-problem', $object)) { + if (! $this->isGrantedOn('icingadb/command/acknowledge-problem', $object)) { return null; } diff --git a/application/forms/Command/Object/AddCommentForm.php b/application/forms/Command/Object/AddCommentForm.php index f3b0ce6d4..3fb0c146e 100644 --- a/application/forms/Command/Object/AddCommentForm.php +++ b/application/forms/Command/Object/AddCommentForm.php @@ -95,7 +95,7 @@ protected function assembleSubmitButton() protected function getCommand(Model $object) { - if (! $this->isGrantedOn('monitoring/command/comment/add', $object)) { + if (! $this->isGrantedOn('icingadb/command/comment/add', $object)) { return null; } diff --git a/application/forms/Command/Object/CheckNowForm.php b/application/forms/Command/Object/CheckNowForm.php index 7f601f761..4f92b0887 100644 --- a/application/forms/Command/Object/CheckNowForm.php +++ b/application/forms/Command/Object/CheckNowForm.php @@ -47,10 +47,10 @@ protected function assembleSubmitButton() protected function getCommand(Model $object) { if ( - ! $this->isGrantedOn('monitoring/command/schedule-check', $object) + ! $this->isGrantedOn('icingadb/command/schedule-check', $object) && ( ! $object->active_checks_enabled - || ! $this->isGrantedOn('monitoring/command/schedule-check/active-only', $object) + || ! $this->isGrantedOn('icingadb/command/schedule-check/active-only', $object) ) ) { return null; diff --git a/application/forms/Command/Object/DeleteCommentForm.php b/application/forms/Command/Object/DeleteCommentForm.php index af2733d30..30db8f7e7 100644 --- a/application/forms/Command/Object/DeleteCommentForm.php +++ b/application/forms/Command/Object/DeleteCommentForm.php @@ -38,10 +38,7 @@ protected function assembleSubmitButton() protected function getCommand(Model $object) { - if (! $this->isGrantedOn( - 'monitoring/command/comment/delete', - $object->{$object->object_type} - )) { + if (! $this->isGrantedOn('icingadb/command/comment/delete', $object->{$object->object_type})) { return null; } diff --git a/application/forms/Command/Object/DeleteDowntimeForm.php b/application/forms/Command/Object/DeleteDowntimeForm.php index 059c00a5a..7853ef756 100644 --- a/application/forms/Command/Object/DeleteDowntimeForm.php +++ b/application/forms/Command/Object/DeleteDowntimeForm.php @@ -40,10 +40,7 @@ protected function assembleSubmitButton() protected function getCommand(Model $object) { - if (! $this->isGrantedOn( - 'monitoring/command/downtime/delete', - $object->{$object->object_type} - )) { + if (! $this->isGrantedOn('icingadb/command/downtime/delete', $object->{$object->object_type})) { return null; } diff --git a/application/forms/Command/Object/ProcessCheckResultForm.php b/application/forms/Command/Object/ProcessCheckResultForm.php index f9b0099c6..c62f78e4d 100644 --- a/application/forms/Command/Object/ProcessCheckResultForm.php +++ b/application/forms/Command/Object/ProcessCheckResultForm.php @@ -103,7 +103,7 @@ protected function assembleSubmitButton() protected function getCommand(Model $object) { - if (! $this->isGrantedOn('monitoring/command/process-check-result', $object)) { + if (! $this->isGrantedOn('icingadb/command/process-check-result', $object)) { return null; } diff --git a/application/forms/Command/Object/RemoveAcknowledgementForm.php b/application/forms/Command/Object/RemoveAcknowledgementForm.php index 1cefe4bc6..c967bd142 100644 --- a/application/forms/Command/Object/RemoveAcknowledgementForm.php +++ b/application/forms/Command/Object/RemoveAcknowledgementForm.php @@ -37,7 +37,7 @@ protected function assembleSubmitButton() protected function getCommand(Model $object) { - if (! $this->isGrantedOn('monitoring/command/remove-acknowledgement', $object)) { + if (! $this->isGrantedOn('icingadb/command/remove-acknowledgement', $object)) { return null; } diff --git a/application/forms/Command/Object/ScheduleCheckForm.php b/application/forms/Command/Object/ScheduleCheckForm.php index 75da58fe2..bf6d439c8 100644 --- a/application/forms/Command/Object/ScheduleCheckForm.php +++ b/application/forms/Command/Object/ScheduleCheckForm.php @@ -75,10 +75,10 @@ protected function assembleSubmitButton() protected function getCommand(Model $object) { if ( - ! $this->isGrantedOn('monitoring/command/schedule-check', $object) + ! $this->isGrantedOn('icingadb/command/schedule-check', $object) && ( ! $object->active_checks_enabled - || ! $this->isGrantedOn('monitoring/command/schedule-check/active-only', $object) + || ! $this->isGrantedOn('icingadb/command/schedule-check/active-only', $object) ) ) { return null; diff --git a/application/forms/Command/Object/ScheduleHostDowntimeForm.php b/application/forms/Command/Object/ScheduleHostDowntimeForm.php index 42799b991..c75152854 100644 --- a/application/forms/Command/Object/ScheduleHostDowntimeForm.php +++ b/application/forms/Command/Object/ScheduleHostDowntimeForm.php @@ -51,7 +51,7 @@ protected function assembleElements() protected function getCommand(Model $object) { - if (! $this->isGrantedOn('monitoring/command/downtime/schedule', $object)) { + if (! $this->isGrantedOn('icingadb/command/downtime/schedule', $object)) { return null; } diff --git a/application/forms/Command/Object/ScheduleServiceDowntimeForm.php b/application/forms/Command/Object/ScheduleServiceDowntimeForm.php index 41fb6a61c..e2e051521 100644 --- a/application/forms/Command/Object/ScheduleServiceDowntimeForm.php +++ b/application/forms/Command/Object/ScheduleServiceDowntimeForm.php @@ -159,7 +159,7 @@ protected function assembleSubmitButton() protected function getCommand(Model $object) { - if (! $this->isGrantedOn('monitoring/command/downtime/schedule', $object)) { + if (! $this->isGrantedOn('icingadb/command/downtime/schedule', $object)) { return null; } diff --git a/application/forms/Command/Object/SendCustomNotificationForm.php b/application/forms/Command/Object/SendCustomNotificationForm.php index b1b0d5e9a..f9e6b08a6 100644 --- a/application/forms/Command/Object/SendCustomNotificationForm.php +++ b/application/forms/Command/Object/SendCustomNotificationForm.php @@ -75,7 +75,7 @@ protected function assembleSubmitButton() protected function getCommand(Model $object) { - if (! $this->isGrantedOn('monitoring/command/send-custom-notification', $object)) { + if (! $this->isGrantedOn('icingadb/command/send-custom-notification', $object)) { return null; } diff --git a/application/forms/Command/Object/ToggleObjectFeaturesForm.php b/application/forms/Command/Object/ToggleObjectFeaturesForm.php index 5a2463cc7..ceaa64847 100644 --- a/application/forms/Command/Object/ToggleObjectFeaturesForm.php +++ b/application/forms/Command/Object/ToggleObjectFeaturesForm.php @@ -26,23 +26,23 @@ public function __construct($featureStatus) $this->features = [ ToggleObjectFeatureCommand::FEATURE_ACTIVE_CHECKS => [ 'label' => t('Active Checks'), - 'permission' => 'monitoring/command/feature/object/active-checks' + 'permission' => 'icingadb/command/feature/object/active-checks' ], ToggleObjectFeatureCommand::FEATURE_PASSIVE_CHECKS => [ 'label' => t('Passive Checks'), - 'permission' => 'monitoring/command/feature/object/passive-checks' + 'permission' => 'icingadb/command/feature/object/passive-checks' ], ToggleObjectFeatureCommand::FEATURE_NOTIFICATIONS => [ 'label' => t('Notifications'), - 'permission' => 'monitoring/command/feature/object/notifications' + 'permission' => 'icingadb/command/feature/object/notifications' ], ToggleObjectFeatureCommand::FEATURE_EVENT_HANDLER => [ 'label' => t('Event Handler'), - 'permission' => 'monitoring/command/feature/object/event-handler' + 'permission' => 'icingadb/command/feature/object/event-handler' ], ToggleObjectFeatureCommand::FEATURE_FLAP_DETECTION => [ 'label' => t('Flap Detection'), - 'permission' => 'monitoring/command/feature/object/flap-detection' + 'permission' => 'icingadb/command/feature/object/flap-detection' ] ]; diff --git a/configuration.php b/configuration.php index 8bfc3142e..a219c3781 100644 --- a/configuration.php +++ b/configuration.php @@ -13,6 +13,87 @@ $this->provideSetupWizard('Icinga\Module\Icingadb\Setup\IcingaDbWizard'); + $this->providePermission( + 'icingadb/command/*', + $this->translate('Allow all commands') + ); + $this->providePermission( + 'icingadb/command/schedule-check', + $this->translate('Allow to schedule host and service checks') + ); + $this->providePermission( + 'icingadb/command/schedule-check/active-only', + $this->translate('Allow to schedule host and service checks (Only on objects with active checks enabled)') + ); + $this->providePermission( + 'icingadb/command/acknowledge-problem', + $this->translate('Allow to acknowledge host and service problems') + ); + $this->providePermission( + 'icingadb/command/remove-acknowledgement', + $this->translate('Allow to remove problem acknowledgements') + ); + $this->providePermission( + 'icingadb/command/comment/*', + $this->translate('Allow to add and delete host and service comments') + ); + $this->providePermission( + 'icingadb/command/comment/add', + $this->translate('Allow to add host and service comments') + ); + $this->providePermission( + 'icingadb/command/comment/delete', + $this->translate('Allow to delete host and service comments') + ); + $this->providePermission( + 'icingadb/command/downtime/*', + $this->translate('Allow to schedule and delete host and service downtimes') + ); + $this->providePermission( + 'icingadb/command/downtime/schedule', + $this->translate('Allow to schedule host and service downtimes') + ); + $this->providePermission( + 'icingadb/command/downtime/delete', + $this->translate('Allow to delete host and service downtimes') + ); + $this->providePermission( + 'icingadb/command/process-check-result', + $this->translate('Allow to process host and service check results') + ); + $this->providePermission( + 'icingadb/command/feature/instance', + $this->translate('Allow to toggle instance-wide features') + ); + $this->providePermission( + 'icingadb/command/feature/object/*', + $this->translate('Allow to toggle all features on host and service objects') + ); + $this->providePermission( + 'icingadb/command/feature/object/active-checks', + $this->translate('Allow to toggle active checks on host and service objects') + ); + $this->providePermission( + 'icingadb/command/feature/object/passive-checks', + $this->translate('Allow to toggle passive checks on host and service objects') + ); + $this->providePermission( + 'icingadb/command/feature/object/notifications', + $this->translate('Allow to toggle notifications on host and service objects') + ); + $this->providePermission( + 'icingadb/command/feature/object/event-handler', + $this->translate('Allow to toggle event handlers on host and service objects') + ); + $this->providePermission( + 'icingadb/command/feature/object/flap-detection', + $this->translate('Allow to toggle flap detection on host and service objects') + ); + $this->providePermission( + 'icingadb/command/send-custom-notification', + $this->translate('Allow to send custom notifications for hosts and services') + ); + $this->provideRestriction( 'icingadb/filter/objects', $this->translate('Restrict access to the Icinga objects that match the filter') diff --git a/library/Icingadb/Common/CommandActions.php b/library/Icingadb/Common/CommandActions.php index ab9a6fe00..1393f5802 100644 --- a/library/Icingadb/Common/CommandActions.php +++ b/library/Icingadb/Common/CommandActions.php @@ -153,22 +153,22 @@ protected function handleCommandForm($form) public function acknowledgeAction() { - $this->assertIsGrantedOnCommandTargets('monitoring/command/acknowledge-problem'); + $this->assertIsGrantedOnCommandTargets('icingadb/command/acknowledge-problem'); $this->setTitle(t('Acknowledge Problem')); $this->handleCommandForm(AcknowledgeProblemForm::class); } public function addCommentAction() { - $this->assertIsGrantedOnCommandTargets('monitoring/command/comment/add'); + $this->assertIsGrantedOnCommandTargets('icingadb/command/comment/add'); $this->setTitle(t('Add Comment')); $this->handleCommandForm(AddCommentForm::class); } public function checkNowAction() { - if (! $this->isGrantedOnCommandTargets('monitoring/command/schedule-check/active-only')) { - $this->assertIsGrantedOnCommandTargets('monitoring/command/schedule-check'); + if (! $this->isGrantedOnCommandTargets('icingadb/command/schedule-check/active-only')) { + $this->assertIsGrantedOnCommandTargets('icingadb/command/schedule-check'); } $this->handleCommandForm(CheckNowForm::class); @@ -176,21 +176,21 @@ public function checkNowAction() public function processCheckresultAction() { - $this->assertIsGrantedOnCommandTargets('monitoring/command/process-check-result'); + $this->assertIsGrantedOnCommandTargets('icingadb/command/process-check-result'); $this->setTitle(t('Submit Passive Check Result')); $this->handleCommandForm(ProcessCheckResultForm::class); } public function removeAcknowledgementAction() { - $this->assertIsGrantedOnCommandTargets('monitoring/command/remove-acknowledgement'); + $this->assertIsGrantedOnCommandTargets('icingadb/command/remove-acknowledgement'); $this->handleCommandForm(RemoveAcknowledgementForm::class); } public function scheduleCheckAction() { - if (! $this->isGrantedOnCommandTargets('monitoring/command/schedule-check/active-only')) { - $this->assertIsGrantedOnCommandTargets('monitoring/command/schedule-check'); + if (! $this->isGrantedOnCommandTargets('icingadb/command/schedule-check/active-only')) { + $this->assertIsGrantedOnCommandTargets('icingadb/command/schedule-check'); } $this->setTitle(t('Reschedule Check')); @@ -199,7 +199,7 @@ public function scheduleCheckAction() public function scheduleDowntimeAction() { - $this->assertIsGrantedOnCommandTargets('monitoring/command/downtime/schedule'); + $this->assertIsGrantedOnCommandTargets('icingadb/command/downtime/schedule'); switch ($this->getCommandTargetModel()->getTableName()) { case 'host': @@ -215,7 +215,7 @@ public function scheduleDowntimeAction() public function sendCustomNotificationAction() { - $this->assertIsGrantedOnCommandTargets('monitoring/command/send-custom-notification'); + $this->assertIsGrantedOnCommandTargets('icingadb/command/send-custom-notification'); $this->setTitle(t('Send Custom Notification')); $this->handleCommandForm(SendCustomNotificationForm::class); } diff --git a/library/Icingadb/Widget/Detail/CommentDetail.php b/library/Icingadb/Widget/Detail/CommentDetail.php index a8e31ac51..009f681ff 100644 --- a/library/Icingadb/Widget/Detail/CommentDetail.php +++ b/library/Icingadb/Widget/Detail/CommentDetail.php @@ -85,10 +85,12 @@ protected function assemble() $this->add($details); } - if ($this->isGrantedOn( - 'monitoring/command/comment/delete', - $this->comment->{$this->comment->object_type} - )) { + if ( + $this->isGrantedOn( + 'icingadb/command/comment/delete', + $this->comment->{$this->comment->object_type} + ) + ) { $this->add($this->createRemoveCommentForm()); } } diff --git a/library/Icingadb/Widget/Detail/DowntimeDetail.php b/library/Icingadb/Widget/Detail/DowntimeDetail.php index 369963fd3..cd15643c5 100644 --- a/library/Icingadb/Widget/Detail/DowntimeDetail.php +++ b/library/Icingadb/Widget/Detail/DowntimeDetail.php @@ -135,10 +135,12 @@ protected function assemble() $this->add(Html::tag('h2', t('Progress'))); $this->add($this->createTimeline()); - if ($this->isGrantedOn( - 'monitoring/command/downtime/delete', - $this->downtime->{$this->downtime->object_type} - )) { + if ( + $this->isGrantedOn( + 'icingadb/command/downtime/delete', + $this->downtime->{$this->downtime->object_type} + ) + ) { $this->add($this->createCancelDowntimeForm()); } } diff --git a/library/Icingadb/Widget/Detail/MultiselectQuickActions.php b/library/Icingadb/Widget/Detail/MultiselectQuickActions.php index 44936f1b6..56a6bd8f1 100644 --- a/library/Icingadb/Widget/Detail/MultiselectQuickActions.php +++ b/library/Icingadb/Widget/Detail/MultiselectQuickActions.php @@ -41,7 +41,7 @@ protected function assemble() if ( $this->summary->$unacknowledged > $this->summary->$acks && $this->isGrantedOnType( - 'monitoring/command/acknowledge-problem', + 'icingadb/command/acknowledge-problem', $this->type, $this->getBaseFilter(), false @@ -58,7 +58,7 @@ protected function assemble() if ( $this->summary->$acks > 0 && $this->isGrantedOnType( - 'monitoring/command/remove-acknowledgement', + 'icingadb/command/remove-acknowledgement', $this->type, $this->getBaseFilter(), false @@ -72,11 +72,11 @@ protected function assemble() } if ( - $this->isGrantedOnType('monitoring/command/schedule-check', $this->type, $this->getBaseFilter(), false) + $this->isGrantedOnType('icingadb/command/schedule-check', $this->type, $this->getBaseFilter(), false) || ( $this->summary->$activeChecks > 0 && $this->isGrantedOnType( - 'monitoring/command/schedule-check/active-only', + 'icingadb/command/schedule-check/active-only', $this->type, $this->getBaseFilter(), false @@ -86,7 +86,7 @@ protected function assemble() $this->add(Html::tag('li', (new CheckNowForm())->setAction($this->getLink('checkNow')))); } - if ($this->isGrantedOnType('monitoring/command/comment/add', $this->type, $this->getBaseFilter(), false)) { + if ($this->isGrantedOnType('icingadb/command/comment/add', $this->type, $this->getBaseFilter(), false)) { $this->assembleAction( 'addComment', t('Comment'), @@ -97,7 +97,7 @@ protected function assemble() if ( $this->isGrantedOnType( - 'monitoring/command/send-custom-notification', + 'icingadb/command/send-custom-notification', $this->type, $this->getBaseFilter(), false @@ -113,7 +113,7 @@ protected function assemble() if ( $this->isGrantedOnType( - 'monitoring/command/downtime/schedule', + 'icingadb/command/downtime/schedule', $this->type, $this->getBaseFilter(), false @@ -128,11 +128,11 @@ protected function assemble() } if ( - $this->isGrantedOnType('monitoring/command/schedule-check', $this->type, $this->getBaseFilter(), false) + $this->isGrantedOnType('icingadb/command/schedule-check', $this->type, $this->getBaseFilter(), false) || ( $this->summary->$activeChecks > 0 && $this->isGrantedOnType( - 'monitoring/command/schedule-check/active-only', + 'icingadb/command/schedule-check/active-only', $this->type, $this->getBaseFilter(), false @@ -149,7 +149,7 @@ protected function assemble() if ( $this->isGrantedOnType( - 'monitoring/command/process-check-result', + 'icingadb/command/process-check-result', $this->type, $this->getBaseFilter(), false diff --git a/library/Icingadb/Widget/Detail/QuickActions.php b/library/Icingadb/Widget/Detail/QuickActions.php index 4394e4e69..08fd0fe8e 100644 --- a/library/Icingadb/Widget/Detail/QuickActions.php +++ b/library/Icingadb/Widget/Detail/QuickActions.php @@ -35,14 +35,14 @@ protected function assemble() { if ($this->object->state->is_problem) { if ($this->object->state->is_acknowledged) { - if ($this->isGrantedOn('monitoring/command/remove-acknowledgement', $this->object)) { + if ($this->isGrantedOn('icingadb/command/remove-acknowledgement', $this->object)) { $removeAckForm = (new RemoveAcknowledgementForm()) ->setAction($this->getLink('removeAcknowledgement')) ->setObjects([$this->object]); $this->add(Html::tag('li', $removeAckForm)); } - } elseif ($this->isGrantedOn('monitoring/command/acknowledge-problem', $this->object)) { + } elseif ($this->isGrantedOn('icingadb/command/acknowledge-problem', $this->object)) { $this->assembleAction( 'acknowledge', t('Acknowledge'), @@ -53,16 +53,16 @@ protected function assemble() } if ( - $this->isGrantedOn('monitoring/command/schedule-check', $this->object) + $this->isGrantedOn('icingadb/command/schedule-check', $this->object) || ( $this->object->active_checks_enabled - && $this->isGrantedOn('monitoring/command/schedule-check/active-only', $this->object) + && $this->isGrantedOn('icingadb/command/schedule-check/active-only', $this->object) ) ) { $this->add(Html::tag('li', (new CheckNowForm())->setAction($this->getLink('checkNow')))); } - if ($this->isGrantedOn('monitoring/command/comment/add', $this->object)) { + if ($this->isGrantedOn('icingadb/command/comment/add', $this->object)) { $this->assembleAction( 'addComment', t('Comment', 'verb'), @@ -71,7 +71,7 @@ protected function assemble() ); } - if ($this->isGrantedOn('monitoring/command/send-custom-notification', $this->object)) { + if ($this->isGrantedOn('icingadb/command/send-custom-notification', $this->object)) { $this->assembleAction( 'sendCustomNotification', t('Notification'), @@ -80,7 +80,7 @@ protected function assemble() ); } - if ($this->isGrantedOn('monitoring/command/downtime/schedule', $this->object)) { + if ($this->isGrantedOn('icingadb/command/downtime/schedule', $this->object)) { $this->assembleAction( 'scheduleDowntime', t('Downtime'), @@ -90,10 +90,10 @@ protected function assemble() } if ( - $this->isGrantedOn('monitoring/command/schedule-check', $this->object) + $this->isGrantedOn('icingadb/command/schedule-check', $this->object) || ( $this->object->active_checks_enabled - && $this->isGrantedOn('monitoring/command/schedule-check/active-only', $this->object) + && $this->isGrantedOn('icingadb/command/schedule-check/active-only', $this->object) ) ) { $this->assembleAction( @@ -104,7 +104,7 @@ protected function assemble() ); } - if ($this->isGrantedOn('monitoring/command/process-check-result', $this->object)) { + if ($this->isGrantedOn('icingadb/command/process-check-result', $this->object)) { $this->assembleAction( 'processCheckresult', t('Process check result'),