Merge pull request #4065 from Icinga/fix/cli-fake-auth
CLI: Setup fake auth
This commit is contained in:
commit
6741217c7f
|
@ -5,6 +5,7 @@ namespace Icinga\Application;
|
|||
|
||||
use Icinga\Application\Platform;
|
||||
use Icinga\Application\ApplicationBootstrap;
|
||||
use Icinga\Authentication\Auth;
|
||||
use Icinga\Cli\Params;
|
||||
use Icinga\Cli\Loader;
|
||||
use Icinga\Cli\Screen;
|
||||
|
@ -12,6 +13,7 @@ use Icinga\Application\Logger;
|
|||
use Icinga\Application\Benchmark;
|
||||
use Icinga\Data\ConfigObject;
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
use Icinga\User;
|
||||
|
||||
require_once __DIR__ . '/ApplicationBootstrap.php';
|
||||
|
||||
|
@ -43,7 +45,8 @@ class Cli extends ApplicationBootstrap
|
|||
->setupLogger()
|
||||
->setupModuleManager()
|
||||
->setupUserBackendFactory()
|
||||
->loadSetupModuleIfNecessary();
|
||||
->loadSetupModuleIfNecessary()
|
||||
->setupFakeAuthentication();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,6 +90,13 @@ class Cli extends ApplicationBootstrap
|
|||
return $this;
|
||||
}
|
||||
|
||||
protected function setupFakeAuthentication()
|
||||
{
|
||||
Auth::getInstance()->setUser(new User('cli'));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function cliLoader()
|
||||
{
|
||||
if ($this->cliLoader === null) {
|
||||
|
|
|
@ -256,6 +256,23 @@ class Auth
|
|||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the authenticated user
|
||||
*
|
||||
* Note that this method just sets the authenticated user and thus bypasses our default authentication process in
|
||||
* {@link setAuthenticated()}.
|
||||
*
|
||||
* @param User $user
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUser(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to authenticate the user with the current session
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue