lib: Add AuthChain::setSkipExternalBackends() in favor of setIteratorMode()
There's only one mode. refs #9660
This commit is contained in:
parent
3ca85f9daa
commit
c3a057dbdb
|
@ -85,7 +85,7 @@ class LoginForm extends Form
|
||||||
{
|
{
|
||||||
$auth = Auth::getInstance();
|
$auth = Auth::getInstance();
|
||||||
$authChain = $auth->getAuthChain();
|
$authChain = $auth->getAuthChain();
|
||||||
$authChain->setIteratorMode($authChain::IT_MODE_NOT_EXTERNAL);
|
$authChain->setSkipExternalBackends(true);
|
||||||
$user = new User($this->getElement('username')->getValue());
|
$user = new User($this->getElement('username')->getValue());
|
||||||
$password = $this->getElement('password')->getValue();
|
$password = $this->getElement('password')->getValue();
|
||||||
$authenticated = $authChain->authenticate($user, $password);
|
$authenticated = $authChain->authenticate($user, $password);
|
||||||
|
@ -107,6 +107,7 @@ class LoginForm extends Form
|
||||||
. ' Please check the system log or Icinga Web 2 log for more information.'
|
. ' Please check the system log or Icinga Web 2 log for more information.'
|
||||||
));
|
));
|
||||||
break;
|
break;
|
||||||
|
/** @noinspection PhpMissingBreakStatementInspection */
|
||||||
case $authChain::ENOTALL:
|
case $authChain::ENOTALL:
|
||||||
$this->addError($this->translate(
|
$this->addError($this->translate(
|
||||||
'Please note that not all authentication methods were available.'
|
'Please note that not all authentication methods were available.'
|
||||||
|
|
|
@ -53,13 +53,6 @@ class AuthChain implements Authenticatable, Iterator
|
||||||
*/
|
*/
|
||||||
const ENOTALL = 4;
|
const ENOTALL = 4;
|
||||||
|
|
||||||
/**
|
|
||||||
* External user backends are excluded by the iterator
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
const IT_MODE_NOT_EXTERNAL = 1;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User backends configuration
|
* User backends configuration
|
||||||
*
|
*
|
||||||
|
@ -82,11 +75,11 @@ class AuthChain implements Authenticatable, Iterator
|
||||||
protected $error;
|
protected $error;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mode of iteration
|
* Whether external user backends should be skipped on iteration
|
||||||
*
|
*
|
||||||
* @var int
|
* @var bool
|
||||||
*/
|
*/
|
||||||
protected $iteratorMode;
|
protected $skipExternalBackends = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new authentication chain from config
|
* Create a new authentication chain from config
|
||||||
|
@ -159,25 +152,25 @@ class AuthChain implements Authenticatable, Iterator
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the iterator mode
|
* Get whether to skip external user backends on iteration
|
||||||
*
|
*
|
||||||
* @return int
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function getIteratorMode()
|
public function getSkipExternalBackends()
|
||||||
{
|
{
|
||||||
return $this->iteratorMode;
|
return $this->skipExternalBackends;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the iterator mode
|
* Set whether to skip external user backends on iteration
|
||||||
*
|
*
|
||||||
* @param int $iteratorMode
|
* @param bool $skipExternalBackends
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setIteratorMode($iteratorMode)
|
public function setSkipExternalBackends($skipExternalBackends = true)
|
||||||
{
|
{
|
||||||
$this->iteratorMode = (int) $iteratorMode;
|
$this->skipExternalBackends = (bool) $skipExternalBackends;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +247,7 @@ class AuthChain implements Authenticatable, Iterator
|
||||||
return $this->valid();
|
return $this->valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->iteratorMode === static::IT_MODE_NOT_EXTERNAL
|
if ($this->getSkipExternalBackends()
|
||||||
&& $backend instanceof ExternalBackend
|
&& $backend instanceof ExternalBackend
|
||||||
) {
|
) {
|
||||||
$this->next();
|
$this->next();
|
||||||
|
|
Loading…
Reference in New Issue