diff --git a/application/forms/Authentication/LoginForm.php b/application/forms/Authentication/LoginForm.php index 537520656..42ff10ed2 100644 --- a/application/forms/Authentication/LoginForm.php +++ b/application/forms/Authentication/LoginForm.php @@ -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) { diff --git a/library/Icinga/Authentication/Auth.php b/library/Icinga/Authentication/Auth.php index 678f777d5..d3974113b 100644 --- a/library/Icinga/Authentication/Auth.php +++ b/library/Icinga/Authentication/Auth.php @@ -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);