Filters sensitive credential fields from auth:fail logs (#1504)

This commit is contained in:
Rain 2025-07-17 16:45:38 -04:00 committed by GitHub
parent 5531bc0ba1
commit 1113ffe0f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,6 +8,10 @@ use Illuminate\Auth\Events\Login;
class AuthenticationListener
{
private const PROTECTED_FIELDS = [
'password', 'token', 'secret',
];
/**
* Handles an authentication event by logging the user and information about
* the request.
@ -22,9 +26,11 @@ class AuthenticationListener
if ($event instanceof Failed) {
foreach ($event->credentials as $key => $value) {
if (!in_array($key, self::PROTECTED_FIELDS, true)) {
$activity = $activity->property($key, $value);
}
}
}
$activity->event($event instanceof Failed ? 'auth:fail' : 'auth:success')->log();
}