mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-28 16:24:05 +02:00
RestApi: allow to override permission check
This commit is contained in:
parent
e562d00a50
commit
475c84de1e
@ -18,13 +18,17 @@ trait RestApi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function assertApiPermission()
|
||||||
|
{
|
||||||
|
if (! $this->hasPermission('director/api')) {
|
||||||
|
throw new AuthenticationException('You are not allowed to access this API');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function checkForRestApiRequest()
|
protected function checkForRestApiRequest()
|
||||||
{
|
{
|
||||||
if ($this->getRequest()->isApiRequest()) {
|
if ($this->getRequest()->isApiRequest()) {
|
||||||
if (! $this->hasPermission('director/api')) {
|
$this->assertApiPermission();
|
||||||
throw new AuthenticationException('You are not allowed to access this API');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $this->isApified()) {
|
if (! $this->isApified()) {
|
||||||
throw new NotFoundError('No such API endpoint found');
|
throw new NotFoundError('No such API endpoint found');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user