mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
parent
79fb8b1e0d
commit
2274b6e11e
@ -7,40 +7,81 @@ use Zend_Config;
|
|||||||
use Icinga\Logger\Logger;
|
use Icinga\Logger\Logger;
|
||||||
use Icinga\Exception\ConfigurationError;
|
use Icinga\Exception\ConfigurationError;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Iterate user backends created from config
|
||||||
|
*/
|
||||||
class AuthChain implements Iterator
|
class AuthChain implements Iterator
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* User backends configuration
|
||||||
|
*
|
||||||
|
* @var Zend_Config
|
||||||
|
*/
|
||||||
private $config;
|
private $config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The consecutive user backend while looping
|
||||||
|
*
|
||||||
|
* @var UserBackend
|
||||||
|
*/
|
||||||
private $currentBackend;
|
private $currentBackend;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new authentication chain from config
|
||||||
|
*
|
||||||
|
* @param Zend_Config $config User backends configuration
|
||||||
|
*/
|
||||||
public function __construct(Zend_Config $config)
|
public function __construct(Zend_Config $config)
|
||||||
{
|
{
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rewind the chain
|
||||||
|
*/
|
||||||
public function rewind()
|
public function rewind()
|
||||||
{
|
{
|
||||||
$this->config->rewind();
|
$this->config->rewind();
|
||||||
|
$this->currentBackend = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the current user backend
|
||||||
|
*
|
||||||
|
* @return UserBackend
|
||||||
|
*/
|
||||||
public function current()
|
public function current()
|
||||||
{
|
{
|
||||||
return $this->currentBackend;
|
return $this->currentBackend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the key of the current user backend config
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function key()
|
public function key()
|
||||||
{
|
{
|
||||||
return $this->config->key();
|
return $this->config->key();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move forward to the next user backend config
|
||||||
|
*/
|
||||||
public function next()
|
public function next()
|
||||||
{
|
{
|
||||||
$this->config->next();
|
$this->config->next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the current user backend is valid, i.e. it's enabled and the config's valid
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function valid()
|
public function valid()
|
||||||
{
|
{
|
||||||
if (!$this->config->valid()) {
|
if (!$this->config->valid()) {
|
||||||
|
// Stop when there are no more backends to check
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$backendConfig = $this->config->current();
|
$backendConfig = $this->config->current();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user