feat: Login anomaly detection system (#124)#770
Open
wocaoac-cpu wants to merge 2 commits intorohitdash08:mainfrom
Open
feat: Login anomaly detection system (#124)#770wocaoac-cpu wants to merge 2 commits intorohitdash08:mainfrom
wocaoac-cpu wants to merge 2 commits intorohitdash08:mainfrom
Conversation
- Add LoginEvent model to track all login attempts (IP, user-agent, timestamp, success/failure) - Add login_anomaly service with real-time risk scoring: - Failed attempt frequency detection - New device/IP detection - Impossible travel detection (login from different geo in short time) - Brute force pattern detection - Add /auth/login-history and /auth/security-status API endpoints - Integrate anomaly detection into existing login flow - Add comprehensive tests (12 test cases) Closes rohitdash08#124
Add SQL migration for login_attempts and login_alerts tables with indexes, and document the /auth/security/* API endpoints in the OpenAPI specification.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Implements login anomaly detection and suspicious activity alerts to detect unusual login behavior and alert users.
Closes #124
What's included
login_anomaly.py) with five real-time detectors:/auth/loginendpoint now returnssecurity_alertsarray when anomalies are detected/auth/security/:GET /auth/security/history— paginated login attempt historyGET /auth/security/alerts— unacknowledged security alerts (with?include_acknowledged=trueoption)POST /auth/security/alerts/{id}/acknowledge— dismiss an alertlogin_attemptsandlogin_alertstables with proper indexesTests
22 test cases covering:
Test plan
pytest tests/test_login_anomaly.py)