Revert "Change setup behavior of the AuthenticationManager to a lazy approach"

This reverts commit 226eb4eded.

Conflicts:
	library/Icinga/Authentication/Manager.php

This fix is not appropriate

refs #5506
This commit is contained in:
Eric Lippmann 2014-02-14 11:20:33 +01:00
parent 9cbfe88ea6
commit d6768872c7
1 changed files with 8 additions and 27 deletions

View File

@ -87,13 +87,6 @@ class Manager
*/
private $config = null;
/**
* If the backends are already created.
*
* @var Boolean
*/
private $initialized = false;
/**
* Creates a new authentication manager using the provided config (or the
* configuration provided in the authentication.ini if no config is given)
@ -110,7 +103,10 @@ class Manager
if ($config === null && !(isset($options['noDefaultConfig']) && $options['noDefaultConfig'] == true)) {
$config = IcingaConfig::app('authentication');
}
$this->config = $config;
if ($config !== null) {
$this->setupBackends($config);
}
}
/**
@ -215,7 +211,6 @@ class Manager
*/
public function getUserBackend($name)
{
$this->initBackends();
return (isset($this->userBackends[$name])) ? $this->userBackends[$name] : null;
}
@ -238,7 +233,6 @@ class Manager
*/
public function getGroupBackend($name)
{
$this->initBackends();
return (isset($this->groupBackends[$name])) ? $this->groupBackends[$name] : null;
}
@ -252,9 +246,8 @@ class Manager
*/
private function getBackendForCredential(Credential $credentials)
{
$this->initBackends();
$authErrors = 0;
foreach ($this->userBackends as $userBackend) {
$flag = false;
@ -298,17 +291,6 @@ class Manager
return null;
}
/**
* Ensures that all backends are initialized
*/
private function initBackends()
{
if (!$this->initialized) {
$this->setupBackends($this->config);
$this->initialized = true;
}
}
/**
* Try to authenticate a user with the given credentials
*
@ -320,13 +302,12 @@ class Manager
*/
public function authenticate(Credential $credentials, $persist = true)
{
$this->initBackends();
if (count($this->userBackends) === 0) {
Logger::error('AuthManager: No authentication backend provided, your users will never be able to login.');
throw new ConfigurationError(
'No authentication backend set - login will never succeed as icinga-web ' .
'doesn\'t know how to determine your user. ' . "\n" .
'To fix this error, setup your authentication.ini with at least one valid authentication backend.'
'No authentication backend set - login will never succeed as icinga-web'
. ' doesn\'t know how to determine your user. ' . "\n"
. ' To fix this error, setup your authentication.ini with at least one valid authentication backend.'
);
}