parent
db505281ee
commit
3aae37aff3
|
@ -128,14 +128,9 @@ class LoginForm extends Form
|
|||
{
|
||||
$auth = Auth::getInstance();
|
||||
$onlyExternal = true;
|
||||
$user = new User('');
|
||||
// TODO(el): This may be set on the auth chain once iterated. See Auth::authExternal().
|
||||
foreach ($auth->getAuthChain() as $backend) {
|
||||
if ($backend instanceof ExternalBackend) {
|
||||
if ($backend->authenticate($user)) {
|
||||
$auth->setAuthenticated($user);
|
||||
$this->getResponse()->setRerenderLayout(true)->redirectAndExit($this->getRedirectUrl());
|
||||
}
|
||||
} else {
|
||||
if (! $backend instanceof ExternalBackend) {
|
||||
$onlyExternal = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ use Exception;
|
|||
use Icinga\Application\Config;
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Authentication\User\ExternalBackend;
|
||||
use Icinga\Authentication\UserGroup\UserGroupBackend;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Exception\IcingaException;
|
||||
|
@ -79,7 +80,11 @@ class Auth
|
|||
*/
|
||||
public function isAuthenticated($ignoreSession = false)
|
||||
{
|
||||
if ($this->user === null && ! $this->authHttp() && ! $ignoreSession) {
|
||||
if ($this->user === null
|
||||
&& ! $this->authHttp()
|
||||
&& ! $this->authExternal()
|
||||
&& ! $ignoreSession
|
||||
) {
|
||||
$this->authenticateFromSession();
|
||||
}
|
||||
return $this->user !== null;
|
||||
|
@ -224,6 +229,25 @@ class Auth
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to authenticate a user from external user backends
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function authExternal()
|
||||
{
|
||||
$user = new User('');
|
||||
foreach ($this->getAuthChain() as $userBackend) {
|
||||
if ($userBackend instanceof ExternalBackend) {
|
||||
if ($userBackend->authenticate($user)) {
|
||||
$this->setAuthenticated($user);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to authenticate a user using HTTP authentication
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue