refactor(security): add typed authentication-success event
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -12,7 +12,6 @@ use KTXF\Event\Event;
|
||||
final class SecurityEvent extends Event implements SecurityRequestEventInterface
|
||||
{
|
||||
// Event names
|
||||
public const AUTH_SUCCESS = 'security.auth.success';
|
||||
public const AUTH_LOGOUT = 'security.auth.logout';
|
||||
public const TOKEN_REFRESH = 'security.token.refresh';
|
||||
public const TOKEN_REVOKED = 'security.token.revoked';
|
||||
@@ -90,32 +89,12 @@ final class SecurityEvent extends Event implements SecurityRequestEventInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an authentication success event
|
||||
*/
|
||||
public static function authSuccess(
|
||||
string $ipAddress,
|
||||
?string $deviceFingerprint = null,
|
||||
?string $userId = null,
|
||||
?string $tenantId = null,
|
||||
): self {
|
||||
return self::create(
|
||||
self::AUTH_SUCCESS,
|
||||
$ipAddress,
|
||||
$deviceFingerprint,
|
||||
['userId' => $userId],
|
||||
tenantId: $tenantId,
|
||||
userId: $userId,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default severity for event types
|
||||
*/
|
||||
private static function getSeverityForEvent(string $eventName): int
|
||||
{
|
||||
return match ($eventName) {
|
||||
self::AUTH_SUCCESS,
|
||||
self::ACCESS_GRANTED,
|
||||
self::TOKEN_REFRESH => self::SEVERITY_INFO,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user