feat(firewall): add scoped log administration reads
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace KTXC\Service;
|
||||
|
||||
use KTXC\Context\IdentityContextInterface;
|
||||
use KTXC\Context\TenantContextInterface;
|
||||
|
||||
final class TenantFirewallLogService
|
||||
{
|
||||
public const PERMISSION_READ = 'firewall.tenant.logs.read';
|
||||
|
||||
public function __construct(
|
||||
private readonly FirewallLogService $logs,
|
||||
private readonly TenantContextInterface $tenant,
|
||||
private readonly IdentityContextInterface $identity,
|
||||
) {
|
||||
}
|
||||
|
||||
public function query(array $filters, int $limit = 50, int $offset = 0): array
|
||||
{
|
||||
if (!$this->identity->hasPermission(self::PERMISSION_READ)) {
|
||||
throw new \RuntimeException('Missing required permission: '.self::PERMISSION_READ);
|
||||
}
|
||||
return $this->logs->tenant($this->tenant->requireIdentifier(), $filters, $limit, $offset);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user