article --summary
The summary
This piece introduces laravel-suspicious-login, a Laravel package that flags unusual logins by combining several signals rather than relying on one, such as an unfamiliar device, a new country or repeated failed attempts. Each check adds points to a score, and configurable thresholds decide whether a login is medium or high risk.
The author walks through a sample preset class that emails users for a new country and blocks logins when a new device and new country are both flagged. It also explains that the checks compare against earlier successful logins, so a first login is never flagged, and that the author recommends monitoring before enabling blocking because travel and VPNs can cause false positives.
The article then covers using different presets for different users, such as admins, customizing the alert email with a subclassed mailable, and listening for the detection event to log suspicious attempts.
Editorial note: This is a summary of an article first published by freek.dev. The full piece is on their site.