This repository was archived by the owner on Jun 19, 2026. It is now read-only.
feat: add login anomaly detection and suspicious activity alerts (closes #124)#150
Open
technologicsingularity wants to merge 1 commit into
Conversation
…sh08#124) Detect unusual login behavior and alert users via response payload. - Brute force protection: block IP after 5 failed attempts (Redis, 10min TTL) - Login event tracking: store last 10 logins per user in Redis (30-day TTL) - Unusual hour detection: warn on logins between 01:00-05:00 UTC - New GET /auth/security-events endpoint: returns recent login history - AuditLog extended with ip_address and details columns - Logs login_success, login_failed, brute_force_blocked events Tests: 27 new tests covering brute force, rate limiting, anomaly detection, security events endpoint, audit logging
Owner
|
@technologicsingularity, can you please share your discord or connect me over discord to discuss this further? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
What's included
New service:
app/services/security.pysecurity_alertfieldlogin_success,login_failed,brute_force_blockedwritten toAuditLogModified:
POST /auth/loginNew endpoint:
GET /auth/security-eventsJWT-protected. Returns last 10 login events for the authenticated user:
{ "events": [ {"ip": "192.168.1.1", "hour": 14, "timestamp": "2026-02-20T14:32:00+00:00"} ] }Modified:
app/models.pyip_address(String 45) anddetails(Text) columns toAuditLogfor richer security event trackingExample: Login with security alert
{ "access_token": "...", "refresh_token": "...", "security_alert": "Login detected at unusual hour (02:34 UTC)" }Validation
./scripts/test-backend.sh)Security and Ownership
main)Checklist