From 8ca6cc32b2c789a3149861159ad258f2cb9491e3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:39:39 +0200 Subject: Adding upstream version 2.11.4. Signed-off-by: Daniel Baumann --- .../monitoring/library/Monitoring/SecurityStep.php | 84 ++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 modules/monitoring/library/Monitoring/SecurityStep.php (limited to 'modules/monitoring/library/Monitoring/SecurityStep.php') diff --git a/modules/monitoring/library/Monitoring/SecurityStep.php b/modules/monitoring/library/Monitoring/SecurityStep.php new file mode 100644 index 0000000..94053b3 --- /dev/null +++ b/modules/monitoring/library/Monitoring/SecurityStep.php @@ -0,0 +1,84 @@ +data = $data; + } + + public function apply() + { + $config = array(); + $config['security'] = $this->data['securityConfig']; + + try { + Config::fromArray($config) + ->setConfigFile(Config::resolvePath('modules/monitoring/config.ini')) + ->saveIni(); + } catch (Exception $e) { + $this->error = $e; + return false; + } + + $this->error = false; + return true; + } + + public function getSummary() + { + $pageTitle = '

' . mt('monitoring', 'Monitoring Security', 'setup.page.title') . '

'; + $pageDescription = '

' . mt( + 'monitoring', + 'Icinga Web 2 will protect your monitoring environment against' + . ' prying eyes using the configuration specified below:' + ) . '

'; + + $pageHtml = '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '
' . mt('monitoring', 'Protected Custom Variables') . '' . ($this->data['securityConfig']['protected_customvars'] ? ( + $this->data['securityConfig']['protected_customvars'] + ) : mt('monitoring', 'None', 'monitoring.protected_customvars')) . '
'; + + return $pageTitle . '
' . $pageDescription . $pageHtml . '
'; + } + + public function getReport() + { + if ($this->error === false) { + return array(sprintf( + mt('monitoring', 'Monitoring security configuration has been successfully created: %s'), + Config::resolvePath('modules/monitoring/config.ini') + )); + } elseif ($this->error !== null) { + return array( + sprintf( + mt( + 'monitoring', + 'Monitoring security configuration could not be written to: %s. An error occured:' + ), + Config::resolvePath('modules/monitoring/config.ini') + ), + sprintf(mt('setup', 'ERROR: %s'), IcingaException::describe($this->error)) + ); + } + } +} -- cgit v1.2.3