From 3dddee8b7d7ce480feb822406adc438ef487166e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 25 Jun 2015 14:36:51 +0200 Subject: [PATCH] Setup: Fix authentication backend validation This is a ridiculous dirty fix. We'll definitely need to improve how we create authentication backends... fixes #9509 --- .../forms/Config/UserBackend/LdapBackendForm.php | 12 ------------ library/Icinga/Authentication/User/UserBackend.php | 7 ++++++- modules/setup/application/forms/AuthBackendPage.php | 10 +++++++++- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/application/forms/Config/UserBackend/LdapBackendForm.php b/application/forms/Config/UserBackend/LdapBackendForm.php index 2402c9a6a..9151134c3 100644 --- a/application/forms/Config/UserBackend/LdapBackendForm.php +++ b/application/forms/Config/UserBackend/LdapBackendForm.php @@ -202,16 +202,4 @@ class LdapBackendForm extends Form return true; } - - /** - * Return the configuration for the chosen resource - * - * @return ConfigObject - * - * @todo Check whether it's possible to drop this (Or even all occurences!) - */ - public function getResourceConfig() - { - return ResourceFactory::getResourceConfig($this->getValue('resource')); - } } diff --git a/library/Icinga/Authentication/User/UserBackend.php b/library/Icinga/Authentication/User/UserBackend.php index 7afd561a7..2bd9e7cae 100644 --- a/library/Icinga/Authentication/User/UserBackend.php +++ b/library/Icinga/Authentication/User/UserBackend.php @@ -163,7 +163,12 @@ class UserBackend $name ); } - $resource = ResourceFactory::create($backendConfig->resource); + + if ($backendConfig->resource instanceof ConfigObject) { + $resource = ResourceFactory::createResource($backendConfig->resource); + } else { + $resource = ResourceFactory::create($backendConfig->resource); + } switch ($backendType) { case 'db': diff --git a/modules/setup/application/forms/AuthBackendPage.php b/modules/setup/application/forms/AuthBackendPage.php index 7590d2f73..7564b577f 100644 --- a/modules/setup/application/forms/AuthBackendPage.php +++ b/modules/setup/application/forms/AuthBackendPage.php @@ -122,7 +122,15 @@ class AuthBackendPage extends Form } if (false === isset($data['skip_validation']) || $data['skip_validation'] == 0) { - if ($this->config['type'] === 'ldap' && false === LdapBackendForm::isValidUserBackend($this)) { + $self = clone $this; + $self->addElement( + 'text', + 'resource', + array( + 'value' => $this->getResourceConfig() + ) + ); + if ($this->config['type'] === 'ldap' && false === LdapBackendForm::isValidUserBackend($self)) { $this->addSkipValidationCheckbox(); return false; }