ConfigController: We're configuring user backends from now on
refs #8826
This commit is contained in:
parent
8875ce7d95
commit
2490d0ae67
|
@ -5,14 +5,15 @@ use Icinga\Application\Config;
|
|||
use Icinga\Application\Icinga;
|
||||
use Icinga\Application\Modules\Module;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Forms\Config\AuthenticationBackendConfigForm;
|
||||
use Icinga\Forms\Config\AuthenticationBackendReorderForm;
|
||||
use Icinga\Forms\Config\UserBackendConfigForm;
|
||||
use Icinga\Forms\Config\UserBackendReorderForm;
|
||||
use Icinga\Forms\Config\GeneralConfigForm;
|
||||
use Icinga\Forms\Config\ResourceConfigForm;
|
||||
use Icinga\Forms\ConfirmRemovalForm;
|
||||
use Icinga\Security\SecurityException;
|
||||
use Icinga\Web\Controller;
|
||||
use Icinga\Web\Notification;
|
||||
use Icinga\Web\Url;
|
||||
use Icinga\Web\Widget;
|
||||
|
||||
/**
|
||||
|
@ -45,13 +46,13 @@ class ConfigController extends Controller
|
|||
));
|
||||
$allowedActions[] = 'general';
|
||||
}
|
||||
if ($auth->hasPermission('config/application/authentication')) {
|
||||
$tabs->add('authentication', array(
|
||||
if ($auth->hasPermission('config/application/userbackend')) {
|
||||
$tabs->add('userbackend', array(
|
||||
'title' => $this->translate('Configure how users authenticate with and log into Icinga Web 2'),
|
||||
'label' => $this->translate('Authentication'),
|
||||
'url' => 'config/authentication'
|
||||
'url' => 'config/userbackend'
|
||||
));
|
||||
$allowedActions[] = 'authentication';
|
||||
$allowedActions[] = 'userbackend';
|
||||
}
|
||||
if ($auth->hasPermission('config/application/resources')) {
|
||||
$tabs->add('resource', array(
|
||||
|
@ -191,71 +192,72 @@ class ConfigController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Action for listing and reordering authentication backends
|
||||
* Action for listing and reordering user backends
|
||||
*/
|
||||
public function authenticationAction()
|
||||
public function userbackendAction()
|
||||
{
|
||||
$this->assertPermission('config/application/authentication');
|
||||
$form = new AuthenticationBackendReorderForm();
|
||||
$this->assertPermission('config/application/userbackend');
|
||||
$form = new UserBackendReorderForm();
|
||||
$form->setIniConfig(Config::app('authentication'));
|
||||
$form->handleRequest();
|
||||
|
||||
$this->view->form = $form;
|
||||
$this->view->tabs->activate('authentication');
|
||||
$this->render('authentication/reorder');
|
||||
$this->view->tabs->activate('userbackend');
|
||||
$this->render('userbackend/reorder');
|
||||
}
|
||||
|
||||
/**
|
||||
* Action for creating a new authentication backend
|
||||
* Action for creating a new user backend
|
||||
*/
|
||||
public function createauthenticationbackendAction()
|
||||
public function createuserbackendAction()
|
||||
{
|
||||
$this->assertPermission('config/application/authentication');
|
||||
$form = new AuthenticationBackendConfigForm();
|
||||
$form->setTitle($this->translate('Create New Authentication Backend'));
|
||||
$this->assertPermission('config/application/userbackend');
|
||||
$form = new UserBackendConfigForm();
|
||||
$form->setTitle($this->translate('Create New User Backend'));
|
||||
$form->addDescription($this->translate(
|
||||
'Create a new backend for authenticating your users. This backend'
|
||||
. ' will be added at the end of your authentication order.'
|
||||
));
|
||||
$form->setIniConfig(Config::app('authentication'));
|
||||
$form->setResourceConfig(ResourceFactory::getResourceConfigs());
|
||||
$form->setRedirectUrl('config/authentication');
|
||||
$form->setRedirectUrl('config/userbackend');
|
||||
$form->handleRequest();
|
||||
|
||||
$this->view->form = $form;
|
||||
$this->view->tabs->activate('authentication');
|
||||
$this->render('authentication/create');
|
||||
$this->view->tabs->activate('userbackend');
|
||||
$this->render('userbackend/create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Action for editing authentication backends
|
||||
* Action for editing user backends
|
||||
*/
|
||||
public function editauthenticationbackendAction()
|
||||
public function edituserbackendAction()
|
||||
{
|
||||
$this->assertPermission('config/application/authentication');
|
||||
$form = new AuthenticationBackendConfigForm();
|
||||
$form->setTitle($this->translate('Edit Backend'));
|
||||
$this->assertPermission('config/application/userbackend');
|
||||
$form = new UserBackendConfigForm();
|
||||
$form->setTitle($this->translate('Edit User Backend'));
|
||||
$form->setIniConfig(Config::app('authentication'));
|
||||
$form->setResourceConfig(ResourceFactory::getResourceConfigs());
|
||||
$form->setRedirectUrl('config/authentication');
|
||||
$form->setRedirectUrl('config/userbackend');
|
||||
$form->setAction(Url::fromRequest());
|
||||
$form->handleRequest();
|
||||
|
||||
$this->view->form = $form;
|
||||
$this->view->tabs->activate('authentication');
|
||||
$this->render('authentication/modify');
|
||||
$this->view->tabs->activate('userbackend');
|
||||
$this->render('userbackend/modify');
|
||||
}
|
||||
|
||||
/**
|
||||
* Action for removing a backend from the authentication list
|
||||
* Action for removing a user backend
|
||||
*/
|
||||
public function removeauthenticationbackendAction()
|
||||
public function removeuserbackendAction()
|
||||
{
|
||||
$this->assertPermission('config/application/authentication');
|
||||
$this->assertPermission('config/application/userbackend');
|
||||
$form = new ConfirmRemovalForm(array(
|
||||
'onSuccess' => function ($form) {
|
||||
$configForm = new AuthenticationBackendConfigForm();
|
||||
$configForm = new UserBackendConfigForm();
|
||||
$configForm->setIniConfig(Config::app('authentication'));
|
||||
$authBackend = $form->getRequest()->getQuery('auth_backend');
|
||||
$authBackend = $form->getRequest()->getQuery('backend');
|
||||
|
||||
try {
|
||||
$configForm->remove($authBackend);
|
||||
|
@ -266,7 +268,7 @@ class ConfigController extends Controller
|
|||
|
||||
if ($configForm->save()) {
|
||||
Notification::success(sprintf(
|
||||
t('Authentication backend "%s" has been successfully removed'),
|
||||
t('User backend "%s" has been successfully removed'),
|
||||
$authBackend
|
||||
));
|
||||
} else {
|
||||
|
@ -274,13 +276,14 @@ class ConfigController extends Controller
|
|||
}
|
||||
}
|
||||
));
|
||||
$form->setTitle($this->translate('Remove Backend'));
|
||||
$form->setRedirectUrl('config/authentication');
|
||||
$form->setTitle($this->translate('Remove User Backend'));
|
||||
$form->setRedirectUrl('config/userbackend');
|
||||
$form->setAction(Url::fromRequest());
|
||||
$form->handleRequest();
|
||||
|
||||
$this->view->form = $form;
|
||||
$this->view->tabs->activate('authentication');
|
||||
$this->render('authentication/remove');
|
||||
$this->view->tabs->activate('userbackend');
|
||||
$this->render('userbackend/remove');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -363,7 +366,7 @@ class ConfigController extends Controller
|
|||
if ($config->get('resource') === $resource) {
|
||||
$form->addDescription(sprintf(
|
||||
$this->translate(
|
||||
'The resource "%s" is currently in use by the authentication backend "%s". ' .
|
||||
'The resource "%s" is currently utilized for authentication by user backend "%s". ' .
|
||||
'Removing the resource can result in noone being able to log in any longer.'
|
||||
),
|
||||
$resource,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||
|
||||
namespace Icinga\Forms\Config\Authentication;
|
||||
namespace Icinga\Forms\Config\UserBackend;
|
||||
|
||||
use Exception;
|
||||
use Icinga\Web\Form;
|
||||
|
@ -10,7 +10,7 @@ use Icinga\Data\ResourceFactory;
|
|||
use Icinga\Authentication\User\DbUserBackend;
|
||||
|
||||
/**
|
||||
* Form class for adding/modifying database authentication backends
|
||||
* Form class for adding/modifying database user backends
|
||||
*/
|
||||
class DbBackendForm extends Form
|
||||
{
|
||||
|
@ -85,13 +85,13 @@ class DbBackendForm extends Form
|
|||
}
|
||||
|
||||
/**
|
||||
* Validate that the selected resource is a valid database authentication backend
|
||||
* Validate that the selected resource is a valid database user backend
|
||||
*
|
||||
* @see Form::onSuccess()
|
||||
*/
|
||||
public function onSuccess()
|
||||
{
|
||||
if (false === static::isValidAuthenticationBackend($this)) {
|
||||
if (false === static::isValidUserBackend($this)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ class DbBackendForm extends Form
|
|||
*
|
||||
* @return bool Whether validation succeeded or not
|
||||
*/
|
||||
public static function isValidAuthenticationBackend(Form $form)
|
||||
public static function isValidUserBackend(Form $form)
|
||||
{
|
||||
try {
|
||||
$dbUserBackend = new DbUserBackend(ResourceFactory::createResource($form->getResourceConfig()));
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||
|
||||
namespace Icinga\Forms\Config\Authentication;
|
||||
namespace Icinga\Forms\Config\UserBackend;
|
||||
|
||||
use Zend_Validate_Callback;
|
||||
use Icinga\Web\Form;
|
||||
|
||||
/**
|
||||
* Form class for adding/modifying authentication backends of type "external"
|
||||
* Form class for adding/modifying user backends of type "external"
|
||||
*/
|
||||
class ExternalBackendForm extends Form
|
||||
{
|
||||
|
@ -90,7 +90,7 @@ class ExternalBackendForm extends Form
|
|||
*
|
||||
* @return bool Whether validation succeeded or not
|
||||
*/
|
||||
public static function isValidAuthenticationBackend(Form $form)
|
||||
public static function isValidUserBackend(Form $form)
|
||||
{
|
||||
return true;
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||
|
||||
namespace Icinga\Forms\Config\Authentication;
|
||||
namespace Icinga\Forms\Config\UserBackend;
|
||||
|
||||
use Exception;
|
||||
use Icinga\Web\Form;
|
||||
|
@ -11,7 +11,7 @@ use Icinga\Exception\AuthenticationException;
|
|||
use Icinga\Authentication\User\LdapUserBackend;
|
||||
|
||||
/**
|
||||
* Form class for adding/modifying LDAP authentication backends
|
||||
* Form class for adding/modifying LDAP user backends
|
||||
*/
|
||||
class LdapBackendForm extends Form
|
||||
{
|
||||
|
@ -149,13 +149,13 @@ class LdapBackendForm extends Form
|
|||
}
|
||||
|
||||
/**
|
||||
* Validate that the selected resource is a valid ldap authentication backend
|
||||
* Validate that the selected resource is a valid ldap user backend
|
||||
*
|
||||
* @see Form::onSuccess()
|
||||
*/
|
||||
public function onSuccess()
|
||||
{
|
||||
if (false === static::isValidAuthenticationBackend($this)) {
|
||||
if (false === static::isValidUserBackend($this)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ class LdapBackendForm extends Form
|
|||
*
|
||||
* @return bool Whether validation succeeded or not
|
||||
*/
|
||||
public static function isValidAuthenticationBackend(Form $form)
|
||||
public static function isValidUserBackend(Form $form)
|
||||
{
|
||||
try {
|
||||
$ldapUserBackend = new LdapUserBackend(ResourceFactory::createResource($form->getResourceConfig()));
|
|
@ -11,11 +11,11 @@ use Icinga\Application\Platform;
|
|||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use Icinga\Forms\Config\Authentication\DbBackendForm;
|
||||
use Icinga\Forms\Config\Authentication\LdapBackendForm;
|
||||
use Icinga\Forms\Config\Authentication\ExternalBackendForm;
|
||||
use Icinga\Forms\Config\UserBackend\DbBackendForm;
|
||||
use Icinga\Forms\Config\UserBackend\LdapBackendForm;
|
||||
use Icinga\Forms\Config\UserBackend\ExternalBackendForm;
|
||||
|
||||
class AuthenticationBackendConfigForm extends ConfigForm
|
||||
class UserBackendConfigForm extends ConfigForm
|
||||
{
|
||||
/**
|
||||
* The available resources split by type
|
||||
|
@ -76,7 +76,7 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||
}
|
||||
|
||||
/**
|
||||
* Add a particular authentication backend
|
||||
* Add a particular user backend
|
||||
*
|
||||
* The backend to add is identified by the array-key `name'.
|
||||
*
|
||||
|
@ -90,9 +90,9 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||
{
|
||||
$name = isset($values['name']) ? $values['name'] : '';
|
||||
if (! $name) {
|
||||
throw new InvalidArgumentException($this->translate('Authentication backend name missing'));
|
||||
throw new InvalidArgumentException($this->translate('User backend name missing'));
|
||||
} elseif ($this->config->hasSection($name)) {
|
||||
throw new InvalidArgumentException($this->translate('Authentication backend already exists'));
|
||||
throw new InvalidArgumentException($this->translate('User backend already exists'));
|
||||
}
|
||||
|
||||
unset($values['name']);
|
||||
|
@ -101,7 +101,7 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||
}
|
||||
|
||||
/**
|
||||
* Edit a particular authentication backend
|
||||
* Edit a particular user backend
|
||||
*
|
||||
* @param string $name The name of the backend to edit
|
||||
* @param array $values The values to edit the configuration with
|
||||
|
@ -113,11 +113,11 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||
public function edit($name, array $values)
|
||||
{
|
||||
if (! $name) {
|
||||
throw new InvalidArgumentException($this->translate('Old authentication backend name missing'));
|
||||
throw new InvalidArgumentException($this->translate('Old user backend name missing'));
|
||||
} elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) {
|
||||
throw new InvalidArgumentException($this->translate('New authentication backend name missing'));
|
||||
throw new InvalidArgumentException($this->translate('New user backend name missing'));
|
||||
} elseif (! $this->config->hasSection($name)) {
|
||||
throw new InvalidArgumentException($this->translate('Unknown authentication backend provided'));
|
||||
throw new InvalidArgumentException($this->translate('Unknown user backend provided'));
|
||||
}
|
||||
|
||||
$backendConfig = $this->config->getSection($name);
|
||||
|
@ -132,7 +132,7 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||
}
|
||||
|
||||
/**
|
||||
* Remove the given authentication backend
|
||||
* Remove the given user backend
|
||||
*
|
||||
* @param string $name The name of the backend to remove
|
||||
*
|
||||
|
@ -143,9 +143,9 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||
public function remove($name)
|
||||
{
|
||||
if (! $name) {
|
||||
throw new InvalidArgumentException($this->translate('Authentication backend name missing'));
|
||||
throw new InvalidArgumentException($this->translate('user backend name missing'));
|
||||
} elseif (! $this->config->hasSection($name)) {
|
||||
throw new InvalidArgumentException($this->translate('Unknown authentication backend provided'));
|
||||
throw new InvalidArgumentException($this->translate('Unknown user backend provided'));
|
||||
}
|
||||
|
||||
$backendConfig = $this->config->getSection($name);
|
||||
|
@ -154,7 +154,7 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||
}
|
||||
|
||||
/**
|
||||
* Move the given authentication backend up or down in order
|
||||
* Move the given user backend up or down in order
|
||||
*
|
||||
* @param string $name The name of the backend to be moved
|
||||
* @param int $position The new (absolute) position of the backend
|
||||
|
@ -166,9 +166,9 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||
public function move($name, $position)
|
||||
{
|
||||
if (! $name) {
|
||||
throw new InvalidArgumentException($this->translate('Authentication backend name missing'));
|
||||
throw new InvalidArgumentException($this->translate('User backend name missing'));
|
||||
} elseif (! $this->config->hasSection($name)) {
|
||||
throw new InvalidArgumentException($this->translate('Unknown authentication backend provided'));
|
||||
throw new InvalidArgumentException($this->translate('Unknown user backend provided'));
|
||||
}
|
||||
|
||||
$backendOrder = $this->config->keys();
|
||||
|
@ -186,7 +186,7 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||
}
|
||||
|
||||
/**
|
||||
* Add or edit an authentication backend and save the configuration
|
||||
* Add or edit an user backend and save the configuration
|
||||
*
|
||||
* Performs a connectivity validation using the submitted values. A checkbox is
|
||||
* added to the form to skip the check if it fails and redirection is aborted.
|
||||
|
@ -197,20 +197,20 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||
{
|
||||
if (($el = $this->getElement('force_creation')) === null || false === $el->isChecked()) {
|
||||
$backendForm = $this->getBackendForm($this->getElement('type')->getValue());
|
||||
if (false === $backendForm::isValidAuthenticationBackend($this)) {
|
||||
if (false === $backendForm::isValidUserBackend($this)) {
|
||||
$this->addElement($this->getForceCreationCheckbox());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$authBackend = $this->request->getQuery('auth_backend');
|
||||
$authBackend = $this->request->getQuery('backend');
|
||||
try {
|
||||
if ($authBackend === null) { // create new backend
|
||||
$this->add($this->getValues());
|
||||
$message = $this->translate('Authentication backend "%s" has been successfully created');
|
||||
$message = $this->translate('User backend "%s" has been successfully created');
|
||||
} else { // edit existing backend
|
||||
$this->edit($authBackend, $this->getValues());
|
||||
$message = $this->translate('Authentication backend "%s" has been successfully changed');
|
||||
$message = $this->translate('User backend "%s" has been successfully changed');
|
||||
}
|
||||
} catch (InvalidArgumentException $e) {
|
||||
Notification::error($e->getMessage());
|
||||
|
@ -225,7 +225,7 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||
}
|
||||
|
||||
/**
|
||||
* Populate the form in case an authentication backend is being edited
|
||||
* Populate the form in case an user backend is being edited
|
||||
*
|
||||
* @see Form::onRequest()
|
||||
*
|
||||
|
@ -233,12 +233,12 @@ class AuthenticationBackendConfigForm extends ConfigForm
|
|||
*/
|
||||
public function onRequest()
|
||||
{
|
||||
$authBackend = $this->request->getQuery('auth_backend');
|
||||
$authBackend = $this->request->getQuery('backend');
|
||||
if ($authBackend !== null) {
|
||||
if ($authBackend === '') {
|
||||
throw new ConfigurationError($this->translate('Authentication backend name missing'));
|
||||
throw new ConfigurationError($this->translate('User backend name missing'));
|
||||
} elseif (! $this->config->hasSection($authBackend)) {
|
||||
throw new ConfigurationError($this->translate('Unknown authentication backend provided'));
|
||||
throw new ConfigurationError($this->translate('Unknown user backend provided'));
|
||||
} elseif ($this->config->getSection($authBackend)->backend === null) {
|
||||
throw new ConfigurationError(
|
||||
sprintf($this->translate('Backend "%s" has no `backend\' setting'), $authBackend)
|
|
@ -7,7 +7,7 @@ use InvalidArgumentException;
|
|||
use Icinga\Web\Notification;
|
||||
use Icinga\Forms\ConfigForm;
|
||||
|
||||
class AuthenticationBackendReorderForm extends ConfigForm
|
||||
class UserBackendReorderForm extends ConfigForm
|
||||
{
|
||||
/**
|
||||
* Initialize this form
|
||||
|
@ -38,7 +38,7 @@ class AuthenticationBackendReorderForm extends ConfigForm
|
|||
}
|
||||
|
||||
/**
|
||||
* Update the authentication backend order and save the configuration
|
||||
* Update the user backend order and save the configuration
|
||||
*
|
||||
* @see Form::onSuccess()
|
||||
*/
|
||||
|
@ -62,13 +62,13 @@ class AuthenticationBackendReorderForm extends ConfigForm
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the config form for authentication backends
|
||||
* Return the config form for user backends
|
||||
*
|
||||
* @return ConfigForm
|
||||
*/
|
||||
protected function getConfigForm()
|
||||
{
|
||||
$form = new AuthenticationBackendConfigForm();
|
||||
$form = new UserBackendConfigForm();
|
||||
$form->setIniConfig($this->config);
|
||||
return $form;
|
||||
}
|
|
@ -25,8 +25,8 @@ class RoleForm extends ConfigForm
|
|||
'config/*' => 'config/*',
|
||||
'config/application/*' => 'config/application/*',
|
||||
'config/application/general' => 'config/application/general',
|
||||
'config/application/authentication' => 'config/application/authentication',
|
||||
'config/application/resources' => 'config/application/resources',
|
||||
'config/application/userbackend' => 'config/application/userbackend',
|
||||
'config/application/usergroupbackend' => 'config/application/usergroupbackend',
|
||||
'config/authentication/*' => 'config/authentication/*',
|
||||
'config/authentication/users/*' => 'config/authentication/users/*',
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
<?= $tabs; ?>
|
||||
</div>
|
||||
<div class="content" data-base-target="_next">
|
||||
<a href="<?= $this->href('/config/createAuthenticationBackend'); ?>">
|
||||
<?= $this->icon('plus'); ?><?= $this->translate('Create A New Authentication Backend'); ?>
|
||||
<a href="<?= $this->href('/config/createuserbackend'); ?>">
|
||||
<?= $this->icon('plus'); ?><?= $this->translate('Create A New User Backend'); ?>
|
||||
</a>
|
||||
<div id="authentication-reorder-form">
|
||||
<?= $form; ?>
|
|
@ -12,22 +12,22 @@
|
|||
<td class="action">
|
||||
<?= $this->qlink(
|
||||
$backendNames[$i],
|
||||
'config/editAuthenticationBackend',
|
||||
array('auth_backend' => $backendNames[$i]),
|
||||
'config/edituserbackend',
|
||||
array('backend' => $backendNames[$i]),
|
||||
array(
|
||||
'icon' => 'edit',
|
||||
'title' => sprintf($this->translate('Edit authentication backend %s'), $backendNames[$i])
|
||||
'title' => sprintf($this->translate('Edit user backend %s'), $backendNames[$i])
|
||||
)
|
||||
); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?= $this->qlink(
|
||||
'',
|
||||
'config/removeAuthenticationBackend',
|
||||
array('auth_backend' => $backendNames[$i]),
|
||||
'config/removeuserbackend',
|
||||
array('backend' => $backendNames[$i]),
|
||||
array(
|
||||
'icon' => 'trash',
|
||||
'title' => sprintf($this->translate('Remove authentication backend %s'), $backendNames[$i])
|
||||
'title' => sprintf($this->translate('Remove user backend %s'), $backendNames[$i])
|
||||
)
|
||||
); ?>
|
||||
</td>
|
||||
|
@ -40,7 +40,7 @@
|
|||
); ?>" title="<?= $this->translate(
|
||||
'Move up in authentication order'
|
||||
); ?>" aria-label="<?= sprintf(
|
||||
$this->translate('Move authentication backend %s upwards'),
|
||||
$this->translate('Move user backend %s upwards'),
|
||||
$backendNames[$i]
|
||||
); ?>">
|
||||
<?= $this->icon('up-big'); ?>
|
||||
|
@ -54,7 +54,7 @@
|
|||
); ?>" title="<?= $this->translate(
|
||||
'Move down in authentication order'
|
||||
); ?>" aria-label="<?= sprintf(
|
||||
$this->translate('Move authentication backend %s downwards'),
|
||||
$this->translate('Move user backend %s downwards'),
|
||||
$backendNames[$i]
|
||||
); ?>">
|
||||
<?= $this->icon('down-big'); ?>
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
namespace Icinga\Module\Setup\Forms;
|
||||
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Forms\Config\Authentication\DbBackendForm;
|
||||
use Icinga\Forms\Config\Authentication\LdapBackendForm;
|
||||
use Icinga\Forms\Config\Authentication\ExternalBackendForm;
|
||||
use Icinga\Forms\Config\UserBackend\DbBackendForm;
|
||||
use Icinga\Forms\Config\UserBackend\LdapBackendForm;
|
||||
use Icinga\Forms\Config\UserBackend\ExternalBackendForm;
|
||||
use Icinga\Data\ConfigObject;
|
||||
|
||||
/**
|
||||
|
@ -105,7 +105,7 @@ class AuthBackendPage extends Form
|
|||
}
|
||||
|
||||
if (false === isset($data['skip_validation']) || $data['skip_validation'] == 0) {
|
||||
if ($this->config['type'] === 'ldap' && false === LdapBackendForm::isValidAuthenticationBackend($this)) {
|
||||
if ($this->config['type'] === 'ldap' && false === LdapBackendForm::isValidUserBackend($this)) {
|
||||
$this->addSkipValidationCheckbox();
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||
|
||||
namespace Tests\Icinga\Forms\Config\Authentication;
|
||||
namespace Tests\Icinga\Forms\Config\UserBackend;
|
||||
|
||||
// Necessary as some of these tests disable phpunit's preservation
|
||||
// of the global state (e.g. autoloaders are in the global state)
|
||||
|
@ -10,7 +10,7 @@ require_once realpath(dirname(__FILE__) . '/../../../../bootstrap.php');
|
|||
use Mockery;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Test\BaseTestCase;
|
||||
use Icinga\Forms\Config\Authentication\DbBackendForm;
|
||||
use Icinga\Forms\Config\UserBackend\DbBackendForm;
|
||||
|
||||
class DbBackendFormTest extends BaseTestCase
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ class DbBackendFormTest extends BaseTestCase
|
|||
->andReturn(2);
|
||||
|
||||
// Passing array(null) is required to make Mockery call the constructor...
|
||||
$form = Mockery::mock('Icinga\Forms\Config\Authentication\DbBackendForm[getView]', array(null));
|
||||
$form = Mockery::mock('Icinga\Forms\Config\UserBackend\DbBackendForm[getView]', array(null));
|
||||
$form->shouldReceive('getView->escape')
|
||||
->with(Mockery::type('string'))
|
||||
->andReturnUsing(function ($s) { return $s; });
|
||||
|
@ -41,8 +41,8 @@ class DbBackendFormTest extends BaseTestCase
|
|||
$form->populate(array('resource' => 'test_db_backend'));
|
||||
|
||||
$this->assertTrue(
|
||||
DbBackendForm::isValidAuthenticationBackend($form),
|
||||
'DbBackendForm claims that a valid authentication backend with users is not valid'
|
||||
DbBackendForm::isValidUserBackend($form),
|
||||
'DbBackendForm claims that a valid user backend with users is not valid'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ class DbBackendFormTest extends BaseTestCase
|
|||
->andReturn(0);
|
||||
|
||||
// Passing array(null) is required to make Mockery call the constructor...
|
||||
$form = Mockery::mock('Icinga\Forms\Config\Authentication\DbBackendForm[getView]', array(null));
|
||||
$form = Mockery::mock('Icinga\Forms\Config\UserBackend\DbBackendForm[getView]', array(null));
|
||||
$form->shouldReceive('getView->escape')
|
||||
->with(Mockery::type('string'))
|
||||
->andReturnUsing(function ($s) { return $s; });
|
||||
|
@ -67,8 +67,8 @@ class DbBackendFormTest extends BaseTestCase
|
|||
$form->populate(array('resource' => 'test_db_backend'));
|
||||
|
||||
$this->assertFalse(
|
||||
DbBackendForm::isValidAuthenticationBackend($form),
|
||||
'DbBackendForm claims that an invalid authentication backend without users is valid'
|
||||
DbBackendForm::isValidUserBackend($form),
|
||||
'DbBackendForm claims that an invalid user backend without users is valid'
|
||||
);
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||
|
||||
namespace Tests\Icinga\Forms\Config\Authentication;
|
||||
namespace Tests\Icinga\Forms\Config\UserBackend;
|
||||
|
||||
// Necessary as some of these tests disable phpunit's preservation
|
||||
// of the global state (e.g. autoloaders are in the global state)
|
||||
|
@ -10,7 +10,7 @@ require_once realpath(dirname(__FILE__) . '/../../../../bootstrap.php');
|
|||
use Mockery;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Test\BaseTestCase;
|
||||
use Icinga\Forms\Config\Authentication\LdapBackendForm;
|
||||
use Icinga\Forms\Config\UserBackend\LdapBackendForm;
|
||||
use Icinga\Exception\AuthenticationException;
|
||||
|
||||
class LdapBackendFormTest extends BaseTestCase
|
||||
|
@ -33,7 +33,7 @@ class LdapBackendFormTest extends BaseTestCase
|
|||
->shouldReceive('setConfig')->andReturnNull();
|
||||
|
||||
// Passing array(null) is required to make Mockery call the constructor...
|
||||
$form = Mockery::mock('Icinga\Forms\Config\Authentication\LdapBackendForm[getView]', array(null));
|
||||
$form = Mockery::mock('Icinga\Forms\Config\UserBackend\LdapBackendForm[getView]', array(null));
|
||||
$form->shouldReceive('getView->escape')
|
||||
->with(Mockery::type('string'))
|
||||
->andReturnUsing(function ($s) { return $s; });
|
||||
|
@ -42,8 +42,8 @@ class LdapBackendFormTest extends BaseTestCase
|
|||
$form->populate(array('resource' => 'test_ldap_backend'));
|
||||
|
||||
$this->assertTrue(
|
||||
LdapBackendForm::isValidAuthenticationBackend($form),
|
||||
'LdapBackendForm claims that a valid authentication backend with users is not valid'
|
||||
LdapBackendForm::isValidUserBackend($form),
|
||||
'LdapBackendForm claims that a valid user backend with users is not valid'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ class LdapBackendFormTest extends BaseTestCase
|
|||
->shouldReceive('assertAuthenticationPossible')->andThrow(new AuthenticationException);
|
||||
|
||||
// Passing array(null) is required to make Mockery call the constructor...
|
||||
$form = Mockery::mock('Icinga\Forms\Config\Authentication\LdapBackendForm[getView]', array(null));
|
||||
$form = Mockery::mock('Icinga\Forms\Config\UserBackend\LdapBackendForm[getView]', array(null));
|
||||
$form->shouldReceive('getView->escape')
|
||||
->with(Mockery::type('string'))
|
||||
->andReturnUsing(function ($s) { return $s; });
|
||||
|
@ -67,8 +67,8 @@ class LdapBackendFormTest extends BaseTestCase
|
|||
$form->populate(array('resource' => 'test_ldap_backend'));
|
||||
|
||||
$this->assertFalse(
|
||||
LdapBackendForm::isValidAuthenticationBackend($form),
|
||||
'LdapBackendForm claims that an invalid authentication backend without users is valid'
|
||||
LdapBackendForm::isValidUserBackend($form),
|
||||
'LdapBackendForm claims that an invalid user backend without users is valid'
|
||||
);
|
||||
}
|
||||
|
|
@ -5,10 +5,10 @@ namespace Tests\Icinga\Forms\Config;
|
|||
|
||||
use Icinga\Test\BaseTestCase;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Forms\Config\AuthenticationBackendConfigForm;
|
||||
use Icinga\Forms\Config\AuthenticationBackendReorderForm;
|
||||
use Icinga\Forms\Config\UserBackendConfigForm;
|
||||
use Icinga\Forms\Config\UserBackendReorderForm;
|
||||
|
||||
class AuthenticationBackendConfigFormWithoutSave extends AuthenticationBackendConfigForm
|
||||
class UserBackendConfigFormWithoutSave extends UserBackendConfigForm
|
||||
{
|
||||
public static $newConfig;
|
||||
|
||||
|
@ -19,11 +19,11 @@ class AuthenticationBackendConfigFormWithoutSave extends AuthenticationBackendCo
|
|||
}
|
||||
}
|
||||
|
||||
class AuthenticationBackendReorderFormProvidingConfigFormWithoutSave extends AuthenticationBackendReorderForm
|
||||
class UserBackendReorderFormProvidingConfigFormWithoutSave extends UserBackendReorderForm
|
||||
{
|
||||
public function getConfigForm()
|
||||
{
|
||||
$form = new AuthenticationBackendConfigFormWithoutSave();
|
||||
$form = new UserBackendConfigFormWithoutSave();
|
||||
$form->setIniConfig($this->config);
|
||||
return $form;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class AuthenticationBackendReorderFormTest extends BaseTestCase
|
|||
->shouldReceive('isPost')->andReturn(true)
|
||||
->shouldReceive('getPost')->andReturn(array('backend_newpos' => 'test3|1'));
|
||||
|
||||
$form = new AuthenticationBackendReorderFormProvidingConfigFormWithoutSave();
|
||||
$form = new UserBackendReorderFormProvidingConfigFormWithoutSave();
|
||||
$form->setIniConfig($config);
|
||||
$form->setTokenDisabled();
|
||||
$form->setUidDisabled();
|
||||
|
@ -53,8 +53,8 @@ class AuthenticationBackendReorderFormTest extends BaseTestCase
|
|||
|
||||
$this->assertEquals(
|
||||
array('test1', 'test3', 'test2'),
|
||||
AuthenticationBackendConfigFormWithoutSave::$newConfig->keys(),
|
||||
'Moving elements with AuthenticationBackendReorderForm does not seem to properly work'
|
||||
UserBackendConfigFormWithoutSave::$newConfig->keys(),
|
||||
'Moving elements with UserBackendReorderForm does not seem to properly work'
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue