From bbe55f28b63e600e5a93b8880caff966a0f9916c Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Thu, 31 Oct 2019 15:43:44 +0100 Subject: [PATCH] config: Allow to disable the Director UI fixes #2007 --- configuration.php | 3 +++ doc/82-Changelog.md | 1 + library/Director/Web/Controller/ActionController.php | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/configuration.php b/configuration.php index 799c52bd..7ee5fb10 100644 --- a/configuration.php +++ b/configuration.php @@ -3,6 +3,9 @@ use Icinga\Application\Icinga; use Icinga\Web\Window; +if ($this->getConfig()->get('frontend', 'disabled', 'no') === 'yes') { + return; +} $this->providePermission('director/api', $this->translate('Allow to access the director API')); $this->providePermission('director/audit', $this->translate('Allow to access the full audit log')); $this->providePermission( diff --git a/doc/82-Changelog.md b/doc/82-Changelog.md index 9ac55726..78fda6ba 100644 --- a/doc/82-Changelog.md +++ b/doc/82-Changelog.md @@ -15,6 +15,7 @@ next (will be 1.8.0) * FIX: It's now possible to set Endpoint ports > 32767 on PostgreSQL (#928) * FEATURE: Data Fields can now be grouped into categories (#1969) * FEATURE: Inspect is now available for Packages, Stages and Files (#1995) +* FEATURE: Allow to disable the Director frontend / UI (#2007) 1.7.2 ----- diff --git a/library/Director/Web/Controller/ActionController.php b/library/Director/Web/Controller/ActionController.php index 129befa3..265abf28 100644 --- a/library/Director/Web/Controller/ActionController.php +++ b/library/Director/Web/Controller/ActionController.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Director\Web\Controller; use Icinga\Application\Benchmark; use Icinga\Data\Paginatable; +use Icinga\Exception\NotFoundError; use Icinga\Exception\ProgrammingError; use Icinga\Module\Director\Monitoring; use Icinga\Module\Director\Web\Controller\Extension\CoreApi; @@ -44,6 +45,11 @@ abstract class ActionController extends Controller implements ControlsAndContent */ public function init() { + if (! $this->getRequest()->isApiRequest() + && $this->Config()->get('frontend', 'disabled', 'no') === 'yes' + ) { + throw new NotFoundError('Not found'); + } $this->initializeTranslator(); Benchmark::measure('Director base Controller init()'); $this->checkForRestApiRequest();