mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
parent
af898cc2b3
commit
50de21e437
@ -294,18 +294,21 @@ class ConfigController extends BaseConfigController
|
|||||||
|
|
||||||
$configArray = IcingaConfig::app('authentication', true)->toArray();
|
$configArray = IcingaConfig::app('authentication', true)->toArray();
|
||||||
$authBackend = $this->getParam('auth_backend');
|
$authBackend = $this->getParam('auth_backend');
|
||||||
if (!isset($configArray[$authBackend])) {
|
if (false === isset($configArray[$authBackend])) {
|
||||||
$this->addErrorMessage('Can\'t edit: Unknown Authentication Backend Provided');
|
$this->addErrorMessage(
|
||||||
$this->configurationerrorAction();
|
$this->translate('Can\'t edit: Unknown Authentication Backend Provided')
|
||||||
return;
|
);
|
||||||
}
|
$this->redirectNow('config/configurationerror');
|
||||||
if (!array_key_exists('resource', $configArray[$authBackend])) {
|
|
||||||
$this->addErrorMessage('Configuration error: Backend "' . $authBackend . '" has no Resource');
|
|
||||||
$this->configurationerrorAction();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$type = ResourceFactory::getResourceConfig($configArray[$authBackend]['resource'])->type;
|
if (false === array_key_exists('backend', $configArray[$authBackend])) {
|
||||||
|
$this->addErrorMessage(sprintf(
|
||||||
|
$this->translate('Backend "%s" has no `backend\' setting'),
|
||||||
|
$authBackend
|
||||||
|
));
|
||||||
|
$this->redirectNow('config/configurationerror');
|
||||||
|
}
|
||||||
|
$type = $configArray[$authBackend]['backend'];
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'ldap':
|
case 'ldap':
|
||||||
$form = new LdapBackendForm();
|
$form = new LdapBackendForm();
|
||||||
@ -313,32 +316,37 @@ class ConfigController extends BaseConfigController
|
|||||||
case 'db':
|
case 'db':
|
||||||
$form = new DbBackendForm();
|
$form = new DbBackendForm();
|
||||||
break;
|
break;
|
||||||
|
case 'autologin':
|
||||||
|
$form = new AutologinBackendForm();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$this->addErrorMessage('Can\'t edit: backend type "' . $type . '" of given resource not supported.');
|
$this->addErrorMessage(sprintf(
|
||||||
$this->configurationerrorAction();
|
$this->translate('Can\'t edit: backend type "%s" of given resource not supported.'),
|
||||||
return;
|
$type
|
||||||
|
));
|
||||||
|
$this->redirectNow('config/configurationerror');
|
||||||
}
|
}
|
||||||
|
|
||||||
$form->setBackendName($this->getParam('auth_backend'));
|
$request = $this->getRequest();
|
||||||
$form->setBackend(IcingaConfig::app('authentication', true)->$authBackend);
|
if ($request->isPost()) {
|
||||||
$form->setRequest($this->getRequest());
|
if ($form->isValid($request->getPost())) {
|
||||||
|
list($backendName, $backendConfig) = $form->getBackendConfig();
|
||||||
if ($form->isSubmittedAndValid()) {
|
$configArray[$backendName] = $backendConfig;
|
||||||
$backendCfg = IcingaConfig::app('authentication')->toArray();
|
|
||||||
foreach ($form->getConfig() as $backendName => $settings) {
|
|
||||||
$backendCfg[$backendName] = $settings;
|
|
||||||
// Remove the old section if the backend is renamed
|
|
||||||
if ($backendName != $authBackend) {
|
if ($backendName != $authBackend) {
|
||||||
unset($backendCfg[$authBackend]);
|
unset($configArray[$authBackend]);
|
||||||
}
|
}
|
||||||
unset($settings['name']);
|
if ($this->writeAuthenticationFile($configArray)) {
|
||||||
|
// redirect to overview with success message
|
||||||
|
Notification::success(sprintf(
|
||||||
|
$this->translate('Backend "%s" saved'),
|
||||||
|
$backendName
|
||||||
|
));
|
||||||
|
$this->redirectNow('config/authentication');
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if ($this->writeAuthenticationFile($backendCfg)) {
|
} else {
|
||||||
// redirect to overview with success message
|
$form->setBackendConfig($authBackend, $configArray[$authBackend]);
|
||||||
Notification::success('Backend "' . $authBackend . '" created');
|
|
||||||
$this->redirectNow("config/authentication");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->view->messageBox->addForm($form);
|
$this->view->messageBox->addForm($form);
|
||||||
|
@ -1,18 +1,8 @@
|
|||||||
<h4>
|
<h4>
|
||||||
<i class="icinga-icon-edit"></i>
|
<?php printf(
|
||||||
Edit Backend "<?= $this->escape($this->name); ?>"
|
$this->translate('Edit Backend "%s"'),
|
||||||
|
$this->escape($this->name)
|
||||||
|
); ?>
|
||||||
</h4>
|
</h4>
|
||||||
|
<?= $messageBox; ?>
|
||||||
<?php if (isset($this->messageBox)): ?>
|
<?= $this->form; ?>
|
||||||
<?= $this->messageBox->render() ?>
|
|
||||||
<?php endif ?>
|
|
||||||
|
|
||||||
<?php if ($this->form->getErrorMessages()): ?>
|
|
||||||
<div>
|
|
||||||
<?php foreach ($this->form->getErrorMessages() as $error): ?>
|
|
||||||
<?= $this->escape($error); ?><br/>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<?= $this->form ?>
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user