Skip to content
Hafiz Syed Shah Ali

All projects

Case study

Suspicious Login Detection

An n8n workflow that enriches each login event, sends a Slack alert with a HIGH, MEDIUM or LOW severity, and emails the user when a new location or device is seen.

The problem

A login from a known malicious IP address, or from a new location or device, should reach the team quickly and with context.

The user should also hear about a login from a place or device they have not used before.

Requirements

  • Built on an n8n community template and extended with custom prompts and integrations.1
  • Free enrichment services: the GreyNoise Community API, IP-API and UserParser.1
  • Shared publicly, so the workflow file holds no client data and no credentials.2

What I built

  1. A webhook receives a login event (a Segment-style track payload).
  2. The IP address and user agent go in parallel to GreyNoise (threat intelligence), IP-API (geolocation) and UserParser (device and browser).
  3. The GreyNoise result (malicious, benign, unknown, RIOT trust level) is mapped to a HIGH, MEDIUM or LOW alert severity and posted to Slack.
  4. If the IP address is not a known threat, the workflow checks the user’s recent login history in Postgres to see whether the location or the device and browser are new.
  5. For a new location or device, it looks up the user’s email address and sends an HTML notice through Gmail.1

How it works

  1. Login eventarrives through a webhook
  2. EnrichGreyNoise, IP-API and UserParser
  3. Set severityHIGH, MEDIUM or LOW, to Slack
  4. Check historyrecent login history
  5. Notify useremail for a new location or device
A login webhook feeds GreyNoise, IP-API and UserParser in parallel. The GreyNoise result becomes a severity and a Slack alert. If the address is not a known threat, the user’s recent login history in Postgres decides whether the location or device is new, and the user gets an email.
Diagram of the Suspicious Login Detection workflow: a login event is enriched by GreyNoise, IP API and UserParser; known threats get a priority (HIGH, MEDIUM or LOW) and a Slack alert; unknown IPs are checked against the user’s recent logins, and the user gets an email for a new location.

Security decisions

  • No credentials in the workflow file: the Postgres, Slack, Gmail and UserParser credentials are created in n8n and selected in the nodes.1
  • The database schema, Slack channel and example values are placeholders.1
  • The public repository was cleaned of client data and scanned for secrets with gitleaks before publishing.2

Results

  • One workflow covers both sides: an alert with a severity for the team in Slack, and a notice to the user for a new location or device.
  • A manual trigger with an example login event is included, so the whole flow can run without a live application.1
  • Public on GitHub with setup steps, ready to import into any n8n instance.3

What I’d do next

From the workflow’s README.1

  • Use a geolocation provider over HTTPS; the free IP-API endpoint is HTTP only.
  • Store each enriched login back in Postgres, to build the login history without a separate tracking pipeline.
  • Add impossible-travel detection: the distance and time between consecutive logins.