Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
c3cb7f6
Allow modules to adjust the CSP headers through a dedicated hook.
w1ll-i-code May 15, 2025
8f8652f
Add additional validation for the url before using it in the frame-sr…
w1ll-i-code May 19, 2025
364de2d
Allow editing of the CSP trusted image sources
TheSyscall Mar 12, 2026
d078935
Refactor CSP validation logic and improve access control for shared n…
zenosaaur Aug 25, 2025
018a920
Refactor CSP handling to improve user checks
zenosaaur Sep 2, 2025
4b31e94
Add a table which displays where a CSP directive comes from
TheSyscall Mar 11, 2026
c0d456b
Move CSP table into its own Widget
TheSyscall Mar 11, 2026
d134e32
Integrate the custom CSP setting
TheSyscall Mar 11, 2026
f1d9222
Use new hook style
TheSyscall Mar 12, 2026
7477372
Custom CSP should completely override the automatically generated one
TheSyscall Mar 12, 2026
af40aca
Allow configuration of the custom CSP-Header
TheSyscall Mar 12, 2026
18156c3
Move the check to send the CSP header into the Csp::isCspEnabled method
TheSyscall Mar 12, 2026
d7128e6
Fix a bug that caused the custom CSP textarea to be empty
TheSyscall Mar 12, 2026
9c83530
Allow for the usage of {style_nonce} in the custom CSP-Header setting
TheSyscall Mar 12, 2026
2061b20
Allow newlines in custom CSP
TheSyscall Mar 12, 2026
54ad4d4
Add dynamic descryption for the custom CSP textarea
TheSyscall Mar 12, 2026
4fec376
Fix code formating
TheSyscall Mar 12, 2026
452bafd
Use generator to iterate the navigation items
TheSyscall Mar 12, 2026
43f78a7
Add info for navigation items
TheSyscall Mar 12, 2026
45c8764
Create style nonce before trying to display the automatic csp
TheSyscall Mar 13, 2026
6130964
Add GPLv2+ license headers
TheSyscall Mar 13, 2026
9990363
Use a callout to display a warning message that is more obvious
TheSyscall Mar 13, 2026
0ee410d
Simplify the way CSP items are collected for dashlets
TheSyscall Mar 13, 2026
fc07616
Use generators instead of iterating over arrays multiple times
TheSyscall Mar 13, 2026
200789c
Write documentation & rename Items to Origins
TheSyscall Mar 13, 2026
88903b0
Remove passive agressive note to admins
TheSyscall Mar 13, 2026
48b9983
Display module name instead of hook class
TheSyscall Mar 13, 2026
4a4130a
Apply code review changes
TheSyscall Mar 16, 2026
dacdf7f
Hide unused form elements and table if CSP is disabled
TheSyscall Mar 16, 2026
2c4b8d2
Automatically reload the window on form success if CSP is active
TheSyscall Mar 16, 2026
749a890
Change URLs in method documentation CspDirectiveHook::getCspDirectives()
TheSyscall Mar 16, 2026
dabf1f8
Use getValue instead of getPopulatedValue
TheSyscall Mar 16, 2026
4601945
Handle update to new value gracefully
TheSyscall Mar 16, 2026
841a30a
Use a hidden element with the same name to store the custom value
TheSyscall Mar 16, 2026
c6d0673
Remove superfluous mentions of CSP inside the Csp class
TheSyscall Mar 16, 2026
33863bc
Add notification
TheSyscall May 19, 2026
74b39de
Default use_custom_csp to 0
TheSyscall Mar 25, 2026
356b049
Remove duplicate default-src directive
TheSyscall Mar 17, 2026
d1eb2b6
Store populated values in hidden form elements
TheSyscall Mar 17, 2026
fdd7ee4
Only store and reload page if necessary
TheSyscall Mar 17, 2026
862f3be
Navigation items that have children can also link to something
TheSyscall Mar 17, 2026
9deb914
Include the port in the navigation URL
TheSyscall Mar 17, 2026
14524c8
Navigation items on the top level should not have themselves as a parent
TheSyscall Mar 17, 2026
9417b20
Use 0/1 instead of n/y for config values
TheSyscall Mar 17, 2026
c7bc5b8
Removed unnecessary call to getUsername
TheSyscall Mar 17, 2026
b890ec3
Use generator to return the collection of CSP-Directives
TheSyscall Mar 17, 2026
461a782
Split CSP-Table into multiple with apropriate headers.
TheSyscall Mar 18, 2026
54db0b5
Hide tables with no content
TheSyscall Mar 18, 2026
3c1a202
Use Link widget
TheSyscall Mar 18, 2026
3990c0d
Move table into form
TheSyscall Mar 18, 2026
7d37049
Change naming of button to "Send CSP-Header"
TheSyscall Mar 18, 2026
45693c3
Color the "data:" schema based on the directive
TheSyscall Mar 19, 2026
00d511c
Code style & Move arrays to class constants
TheSyscall Mar 19, 2026
f418ad5
Code review changes
TheSyscall Mar 20, 2026
2074525
Prefixed CSS-classes with `csp-`
TheSyscall Mar 23, 2026
a552326
Add a toggle to enable user content
TheSyscall Mar 20, 2026
dedb1e6
Move CSP-Form into a newly created Security tab.
TheSyscall Mar 20, 2026
1b17cac
Code review suggestions
TheSyscall Mar 20, 2026
021ad89
Use new Csp class in ipl-web
TheSyscall Mar 20, 2026
084e414
Code style changes
TheSyscall Mar 23, 2026
c82760c
Rework Csp to no longer rely on a private instance just to store the …
TheSyscall Mar 23, 2026
e77025e
Add form validation
TheSyscall Mar 23, 2026
2a7378b
Merge CspConfigurationTable with form
TheSyscall Mar 24, 2026
4386b95
Code review changes
TheSyscall Apr 1, 2026
2fe75bc
Rename schema to scheme
TheSyscall May 18, 2026
e6551e6
Add rel="noopener noreferrer"
TheSyscall May 18, 2026
6c25049
Store security seection in config even if the section didn't exist be…
TheSyscall Mar 25, 2026
497ba28
Log errors during Csp loading
TheSyscall Mar 25, 2026
0a7ad02
Return Csp instances instead of raw arrays
TheSyscall Mar 25, 2026
c541976
Change Hook name to CspHook
TheSyscall Mar 25, 2026
7b9fcbc
Make tables collapsible
TheSyscall Mar 25, 2026
e6223bc
Split title from table
TheSyscall Apr 1, 2026
be1f91c
Indent polices if an icon exists in the table
TheSyscall Apr 1, 2026
16f2e94
Return an empty array instead of throwing an error
TheSyscall Apr 1, 2026
19274ae
Change license and use SPDX-Header
TheSyscall Apr 1, 2026
c483478
Display the label of the navigation type instead of its internal type
TheSyscall Apr 2, 2026
bb3a985
Write documentation
TheSyscall Mar 26, 2026
25f6fc5
Change policy to expression to be more spec compliant
TheSyscall Apr 9, 2026
fd4d0f7
Add helper methods for accessing the currently active csp configuration
TheSyscall May 18, 2026
0ab7f70
Display an info callout when adding dashlets or custom navigation items
TheSyscall Apr 15, 2026
1ca96b2
List all users dashboard entries
TheSyscall May 13, 2026
5d8571e
List all users navigation items
TheSyscall May 13, 2026
92eb993
Better translations for table headers
TheSyscall May 18, 2026
4b88a49
Handle all navigation types and respect share permissions
TheSyscall May 18, 2026
49b9562
Refactor LoadedCsp to no longer extend Csp
TheSyscall May 18, 2026
f88cffb
Check if the directory exists before iterating
TheSyscall May 19, 2026
2e1754d
Rename LoadedCsp to AttributedCsp
TheSyscall May 18, 2026
1b33e08
Move the allUsers flag to the load method
TheSyscall May 19, 2026
732d1eb
Use $this->translate instead of t()
TheSyscall May 19, 2026
ceeeee3
Reword docstrings
TheSyscall May 19, 2026
4bc4dc3
Use array for class list
TheSyscall May 19, 2026
b7105d1
Gracefully handle the case where there is no owner defined
TheSyscall May 19, 2026
11ceca2
Rename disabledState to useCustomCsp
TheSyscall May 19, 2026
4896f24
Properly check for changes in the configuration
TheSyscall May 19, 2026
48bdb51
Add security to fallback list
TheSyscall May 19, 2026
7fa22c5
fixup! phpcs
TheSyscall May 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 51 additions & 12 deletions application/controllers/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace Icinga\Controllers;

use Exception;
use GuzzleHttp\Psr7\ServerRequest;
use Icinga\Application\Version;
use InvalidArgumentException;
use Icinga\Application\Config;
Expand All @@ -17,6 +18,7 @@
use Icinga\Forms\ActionForm;
use Icinga\Forms\Config\GeneralConfigForm;
use Icinga\Forms\Config\ResourceConfigForm;
use Icinga\Forms\Config\Security\CspConfigForm;
use Icinga\Forms\Config\UserBackendConfigForm;
use Icinga\Forms\Config\UserBackendReorderForm;
use Icinga\Forms\ConfirmRemovalForm;
Expand All @@ -25,6 +27,7 @@
use Icinga\Web\Notification;
use Icinga\Web\Url;
use Icinga\Web\Widget;
use ipl\Html\Contract\Form as ContractForm;

/**
* Application and module configuration
Expand All @@ -45,6 +48,14 @@ public function createApplicationTabs()
'baseTarget' => '_main'
));
}
if ($this->hasPermission('config/security')) {
$tabs->add('security', array(
'title' => $this->translate('Adjust the security configuration of Icinga Web 2'),
'label' => $this->translate('Security'),
'url' => 'config/security',
'baseTarget' => '_main'
));
}
if ($this->hasPermission('config/resources')) {
$tabs->add('resource', array(
'title' => $this->translate('Configure which resources are being utilized by Icinga Web 2'),
Expand Down Expand Up @@ -79,6 +90,8 @@ public function indexAction()
{
if ($this->hasPermission('config/general')) {
$this->redirectNow('config/general');
} elseif ($this->hasPermission('config/security')) {
$this->redirectNow('config/security');
} elseif ($this->hasPermission('config/resources')) {
$this->redirectNow('config/resource');
} elseif ($this->hasPermission('config/access-control/*')) {
Expand All @@ -96,24 +109,50 @@ public function indexAction()
public function generalAction()
{
$this->assertPermission('config/general');

$this->view->title = $this->translate('General');

$form = new GeneralConfigForm();
$form->setIniConfig(Config::app());
$form->setOnSuccess(function (GeneralConfigForm $form) {
$config = Config::app();
$useStrictCsp = (bool) $config->get('security', 'use_strict_csp', false);
if ($form->onSuccess() === false) {
return false;
}
$form->handleRequest();

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

$appConfigForm = $form->getSubForm('form_config_general_application');
if ($appConfigForm && (bool) $appConfigForm->getValue('security_use_strict_csp') !== $useStrictCsp) {
$this->createApplicationTabs()->activate('general');
}

/**
* Security configuration
*
* @throws SecurityException If the user lacks the permission for configuring the security configuration
*/
public function securityAction(): void
{
$this->assertPermission('config/security');

$this->view->title = $this->translate('Security');

$config = Config::app();
$cspForm = new CspConfigForm($config);
$cspForm->populate([
'use_strict_csp' => $config->get('security', 'use_strict_csp', '0'),
'use_custom_csp' => $config->get('security', 'use_custom_csp', '0'),
'custom_csp' => $config->get('security', 'custom_csp', ''),
'csp_enable_modules' => $config->get('security', 'csp_enable_modules', '1'),
'csp_enable_dashboards' => $config->get('security', 'csp_enable_dashboards', '1'),
'csp_enable_navigation' => $config->get('security', 'csp_enable_navigation', '1'),
]);

$cspForm->on(ContractForm::ON_SUBMIT, function (CspConfigForm $form) {
if ($form->hasConfigChanged()) {
$this->getResponse()->setReloadWindow(true);
Comment thread
Al2Klimov marked this conversation as resolved.
}
})->handleRequest();
Notification::success($this->translate('Content-Security-Policy updated'));
});
$cspForm->handleRequest(ServerRequest::fromGlobals());
$this->view->cspForm = $cspForm;

$this->view->form = $form;
$this->view->title = $this->translate('General');
$this->createApplicationTabs()->activate('general');
$this->createApplicationTabs()->activate('security');
}

/**
Expand Down
12 changes: 0 additions & 12 deletions application/forms/Config/General/ApplicationConfigForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,6 @@ public function createElements(array $formData)
)
);

$this->addElement(
'checkbox',
'security_use_strict_csp',
[
'label' => $this->translate('Enable strict content security policy'),
'description' => $this->translate(
'Set whether to use strict content security policy (CSP).'
. ' This setting helps to protect from cross-site scripting (XSS).'
)
]
);

$this->addElement(
'text',
'global_module_path',
Expand Down
Loading
Loading