fix(firewall): enforce system rules independently of tenant context
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -10,20 +10,30 @@ use KTXC\Stores\FirewallStore;
|
||||
final class FirewallRuleCache
|
||||
{
|
||||
/** @var array<string, FirewallRuleObject[]> */
|
||||
private array $rules = [];
|
||||
private array $tenantRules = [];
|
||||
|
||||
/** @var FirewallRuleObject[]|null */
|
||||
private ?array $systemRules = null;
|
||||
|
||||
public function __construct(private readonly FirewallStore $store)
|
||||
{
|
||||
}
|
||||
|
||||
/** @return FirewallRuleObject[] */
|
||||
public function applicable(string $tenantId): array
|
||||
public function tenant(string $tenantId): array
|
||||
{
|
||||
return $this->rules[$tenantId] ??= $this->store->listApplicableRules($tenantId);
|
||||
return $this->tenantRules[$tenantId] ??= $this->store->listRules($tenantId);
|
||||
}
|
||||
|
||||
/** @return FirewallRuleObject[] */
|
||||
public function system(): array
|
||||
{
|
||||
return $this->systemRules ??= $this->store->listSystemRules();
|
||||
}
|
||||
|
||||
public function invalidate(): void
|
||||
{
|
||||
$this->rules = [];
|
||||
$this->tenantRules = [];
|
||||
$this->systemRules = null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user