Skip to content

Commit f9f19b4

Browse files
committed
Move CSP-Form into a newly created Security tab.
This tab requires the new config/security permission
1 parent b6269a9 commit f9f19b4

File tree

4 files changed

+33
-7
lines changed

4 files changed

+33
-7
lines changed

application/controllers/ConfigController.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Icinga\Application\Version;
99
use Icinga\Forms\Config\General\CspConfigForm;
1010
use Icinga\Util\Csp;
11-
use Icinga\Web\Widget\CspConfigurationTable;
1211
use InvalidArgumentException;
1312
use Icinga\Application\Config;
1413
use Icinga\Application\Icinga;
@@ -28,7 +27,6 @@
2827
use Icinga\Web\Url;
2928
use Icinga\Web\Widget;
3029
use ipl\Html\Contract\Form as ContractForm;
31-
use ipl\Html\Form;
3230

3331
/**
3432
* Application and module configuration
@@ -49,6 +47,14 @@ public function createApplicationTabs()
4947
'baseTarget' => '_main'
5048
));
5149
}
50+
if ($this->hasPermission('config/security')) {
51+
$tabs->add('security', array(
52+
'title' => $this->translate('Adjust the security configuration of Icinga Web 2'),
53+
'label' => $this->translate('Security'),
54+
'url' => 'config/security',
55+
'baseTarget' => '_main'
56+
));
57+
}
5258
if ($this->hasPermission('config/resources')) {
5359
$tabs->add('resource', array(
5460
'title' => $this->translate('Configure which resources are being utilized by Icinga Web 2'),
@@ -109,6 +115,20 @@ public function generalAction()
109115

110116
$this->view->form = $form;
111117

118+
$this->createApplicationTabs()->activate('general');
119+
}
120+
121+
/**
122+
* Security configuration
123+
*
124+
* @throws SecurityException If the user lacks the permission for configuring the security configuration
125+
*/
126+
public function securityAction()
127+
{
128+
$this->assertPermission('config/security');
129+
130+
$this->view->title = $this->translate('General');
131+
112132
$config = Config::app();
113133
$cspForm = new CspConfigForm($config);
114134
$cspForm->populate([
@@ -127,7 +147,7 @@ public function generalAction()
127147
$cspForm->handleRequest(ServerRequest::fromGlobals());
128148
$this->view->cspForm = $cspForm;
129149

130-
$this->createApplicationTabs()->activate('general');
150+
$this->createApplicationTabs()->activate('security');
131151
}
132152

133153
/**

application/forms/Security/RoleForm.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,9 @@ public static function collectProvidedPrivileges()
546546
'config/general' => [
547547
'description' => t('Allow to adjust the general configuration')
548548
],
549+
'config/security' => [
550+
'description' => t('Allow to adjust the security configuration')
551+
],
549552
'config/modules' => [
550553
'description' => t('Allow to enable/disable and configure modules')
551554
],

application/views/scripts/config/general.phtml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,5 @@
22
<?= $tabs ?>
33
</div>
44
<div class="content">
5-
<h2><?= $this->translate('General') ?></h2>
65
<?= $form ?>
7-
8-
<h2><?= $this->translate('Content Security Policy') ?></h2>
9-
<?= $cspForm ?>
106
</div>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div class="controls">
2+
<?= $tabs ?>
3+
</div>
4+
<div class="content">
5+
<h2><?= $this->translate('Content Security Policy') ?></h2>
6+
<?= $cspForm ?>
7+
</div>

0 commit comments

Comments
 (0)