refactor(security): type firewall policy events
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -11,9 +11,11 @@ use KTXC\Security\Event\FirewallRuleEnabledEvent;
|
||||
use KTXC\Security\Event\FirewallRuleEvent;
|
||||
use KTXC\Security\Event\FirewallRuleExtendedEvent;
|
||||
use KTXC\Security\Event\FirewallRuleRemovedEvent;
|
||||
use KTXC\Security\Event\DeviceBlockedEvent;
|
||||
use KTXC\Security\Event\IpAllowedEvent;
|
||||
use KTXC\Security\Event\IpBlockedEvent;
|
||||
use KTXC\Stores\FirewallStore;
|
||||
use KTXF\Event\EventDispatcherInterface;
|
||||
use KTXC\Security\Event\SecurityEvent;
|
||||
use KTXF\IpUtils;
|
||||
|
||||
final class FirewallRuleManager
|
||||
@@ -192,7 +194,7 @@ final class FirewallRuleManager
|
||||
$origin,
|
||||
$metadata
|
||||
);
|
||||
$this->publishIpEvent(SecurityEvent::IP_BLOCKED, $scope, $ipAddress, $reason);
|
||||
$this->events->dispatch(new IpBlockedEvent($ipAddress, $reason, $scope->tenantId));
|
||||
|
||||
return $rule;
|
||||
}
|
||||
@@ -215,7 +217,7 @@ final class FirewallRuleManager
|
||||
null,
|
||||
$origin
|
||||
);
|
||||
$this->publishIpEvent(SecurityEvent::IP_ALLOWED, $scope, $ipAddress, $reason);
|
||||
$this->events->dispatch(new IpAllowedEvent($ipAddress, $reason, $scope->tenantId));
|
||||
|
||||
return $rule;
|
||||
}
|
||||
@@ -260,13 +262,7 @@ final class FirewallRuleManager
|
||||
$origin
|
||||
);
|
||||
|
||||
$event = new SecurityEvent(
|
||||
SecurityEvent::DEVICE_BLOCKED,
|
||||
['device' => $fingerprint, 'reason' => $reason],
|
||||
tenantId: $scope->tenantId,
|
||||
deviceFingerprint: $fingerprint,
|
||||
reason: $reason,
|
||||
);
|
||||
$event = new DeviceBlockedEvent($fingerprint, $reason, $scope->tenantId);
|
||||
$this->events->dispatch($event);
|
||||
|
||||
return $rule;
|
||||
@@ -505,22 +501,6 @@ final class FirewallRuleManager
|
||||
return $rule && $scope->owns($rule) ? $rule : null;
|
||||
}
|
||||
|
||||
private function publishIpEvent(
|
||||
string $name,
|
||||
FirewallRuleScope $scope,
|
||||
string $ipAddress,
|
||||
?string $reason
|
||||
): void {
|
||||
$event = new SecurityEvent(
|
||||
$name,
|
||||
['ip' => $ipAddress, 'reason' => $reason],
|
||||
tenantId: $scope->tenantId,
|
||||
ipAddress: $ipAddress,
|
||||
reason: $reason,
|
||||
);
|
||||
$this->events->dispatch($event);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string<FirewallRuleEvent> $eventClass
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user