mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 15:54:03 +02:00
CLI: Setup fake auth
Since version 2.7.x CLI actions load all enabled modules automatically. This includes launching configuration.php and run.php. Though code in those files should be restricted to a supported set of functions, module devs may write any code here. If a module requires authentication in those files, CLI actions fail because there is no auth possible. With this patch, we setup a fake user named "cli" w/o any permission when running CLI actions.
This commit is contained in:
parent
990a5e4d61
commit
3361cac59a
@ -5,6 +5,7 @@ namespace Icinga\Application;
|
|||||||
|
|
||||||
use Icinga\Application\Platform;
|
use Icinga\Application\Platform;
|
||||||
use Icinga\Application\ApplicationBootstrap;
|
use Icinga\Application\ApplicationBootstrap;
|
||||||
|
use Icinga\Authentication\Auth;
|
||||||
use Icinga\Cli\Params;
|
use Icinga\Cli\Params;
|
||||||
use Icinga\Cli\Loader;
|
use Icinga\Cli\Loader;
|
||||||
use Icinga\Cli\Screen;
|
use Icinga\Cli\Screen;
|
||||||
@ -12,6 +13,7 @@ use Icinga\Application\Logger;
|
|||||||
use Icinga\Application\Benchmark;
|
use Icinga\Application\Benchmark;
|
||||||
use Icinga\Data\ConfigObject;
|
use Icinga\Data\ConfigObject;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
|
use Icinga\User;
|
||||||
|
|
||||||
require_once __DIR__ . '/ApplicationBootstrap.php';
|
require_once __DIR__ . '/ApplicationBootstrap.php';
|
||||||
|
|
||||||
@ -43,7 +45,8 @@ class Cli extends ApplicationBootstrap
|
|||||||
->setupLogger()
|
->setupLogger()
|
||||||
->setupModuleManager()
|
->setupModuleManager()
|
||||||
->setupUserBackendFactory()
|
->setupUserBackendFactory()
|
||||||
->loadSetupModuleIfNecessary();
|
->loadSetupModuleIfNecessary()
|
||||||
|
->setupFakeAuthentication();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -87,6 +90,13 @@ class Cli extends ApplicationBootstrap
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function setupFakeAuthentication()
|
||||||
|
{
|
||||||
|
Auth::getInstance()->setUser(new User('cli'));
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function cliLoader()
|
public function cliLoader()
|
||||||
{
|
{
|
||||||
if ($this->cliLoader === null) {
|
if ($this->cliLoader === null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user