fix(firewall): enforce system rules independently of tenant context
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -55,43 +55,6 @@ class FirewallStore
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* List active system-wide rules and active rules owned by a tenant.
|
||||
*/
|
||||
public function listApplicableRules(string $tenantId): array
|
||||
{
|
||||
$now = (new \DateTimeImmutable())->format(\DateTimeInterface::ATOM);
|
||||
$filter = [
|
||||
'enabled' => true,
|
||||
'$and' => [
|
||||
[
|
||||
'$or' => [
|
||||
['scope' => FirewallRuleObject::SCOPE_SYSTEM],
|
||||
[
|
||||
'tenantId' => $tenantId,
|
||||
'scope' => FirewallRuleObject::SCOPE_TENANT,
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'$or' => [
|
||||
['expiresAt' => null],
|
||||
['expiresAt' => ['$gt' => $now]],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$cursor = $this->dataStore->selectCollection(self::RULES_COLLECTION)->find($filter);
|
||||
$list = [];
|
||||
|
||||
foreach ($cursor as $entry) {
|
||||
$list[] = (new FirewallRuleObject())->jsonDeserialize((array)$entry);
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function listSystemRules(bool $activeOnly = true): array
|
||||
{
|
||||
$filter = ['scope' => FirewallRuleObject::SCOPE_SYSTEM, 'tenantId' => null];
|
||||
|
||||
Reference in New Issue
Block a user