refactor(kernel): unify HTTP and CLI application lifecycle
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -2,6 +2,10 @@
|
||||
|
||||
namespace KTXC\Module;
|
||||
|
||||
use KTXC\Service\FirewallService;
|
||||
use KTXF\Event\DeliveryMode;
|
||||
use KTXF\Event\EventListenerRegistry;
|
||||
use KTXF\Event\SecurityEvent;
|
||||
use KTXF\Module\ModuleBrowserInterface;
|
||||
use KTXF\Module\ModuleConsoleInterface;
|
||||
use KTXF\Module\ModuleInstanceAbstract;
|
||||
@@ -13,7 +17,36 @@ use KTXF\Module\ModuleInstanceAbstract;
|
||||
*/
|
||||
class Module extends ModuleInstanceAbstract implements ModuleConsoleInterface, ModuleBrowserInterface
|
||||
{
|
||||
public function __construct() {}
|
||||
public function __construct(
|
||||
private readonly EventListenerRegistry $events,
|
||||
) {
|
||||
}
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
$this->events->listen(
|
||||
'core',
|
||||
SecurityEvent::AUTH_FAILURE,
|
||||
FirewallService::class,
|
||||
'handleAuthFailure',
|
||||
priority: 100,
|
||||
);
|
||||
|
||||
foreach ([
|
||||
SecurityEvent::AUTH_FAILURE,
|
||||
SecurityEvent::AUTH_SUCCESS,
|
||||
SecurityEvent::ACCESS_DENIED,
|
||||
SecurityEvent::BRUTE_FORCE_DETECTED,
|
||||
] as $event) {
|
||||
$this->events->listen(
|
||||
'core',
|
||||
$event,
|
||||
FirewallService::class,
|
||||
'logSecurityEvent',
|
||||
DeliveryMode::Deferred,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(): string
|
||||
{
|
||||
@@ -99,6 +132,7 @@ class Module extends ModuleInstanceAbstract implements ModuleConsoleInterface, M
|
||||
public function registerCI(): array
|
||||
{
|
||||
return [
|
||||
\KTXC\Console\Event\EventsDebugCommand::class,
|
||||
\KTXC\Console\Module\ModuleListCommand::class,
|
||||
\KTXC\Console\Module\ModuleEnableCommand::class,
|
||||
\KTXC\Console\Module\ModuleDisableCommand::class,
|
||||
|
||||
Reference in New Issue
Block a user