Login: set the default domain if necessary

refs #2153
This commit is contained in:
Eric Lippmann 2017-06-07 14:21:42 +02:00 committed by Alexander A. Klimov
parent 1a5e64eda9
commit 41acffdc24
2 changed files with 10 additions and 0 deletions

View File

@ -3,6 +3,7 @@
namespace Icinga\Forms\Authentication;
use Icinga\Application\Config;
use Icinga\Authentication\Auth;
use Icinga\Authentication\User\ExternalBackend;
use Icinga\User;
@ -87,6 +88,9 @@ class LoginForm extends Form
$authChain = $auth->getAuthChain();
$authChain->setSkipExternalBackends(true);
$user = new User($this->getElement('username')->getValue());
if (! $user->hasDomain()) {
$user->setDomain(Config::app()->get('authentication', 'default_domain'));
}
$password = $this->getElement('password')->getValue();
$authenticated = $authChain->authenticate($user, $password);
if ($authenticated) {

View File

@ -259,6 +259,9 @@ class Auth
foreach ($this->getAuthChain() as $userBackend) {
if ($userBackend instanceof ExternalBackend) {
if ($userBackend->authenticate($user)) {
if (! $user->hasDomain()) {
$user->setDomain(Config::app()->get('authentication', 'default_domain'));
}
$this->setAuthenticated($user);
return true;
}
@ -293,6 +296,9 @@ class Auth
return false;
}
$user = new User($credentials[0]);
if (! $user->hasDomain()) {
$user->setDomain(Config::app()->get('authentication', 'default_domain'));
}
$password = $credentials[1];
if ($this->getAuthChain()->setSkipExternalBackends(true)->authenticate($user, $password)) {
$this->setAuthenticated($user, false);