Source: factory.core/ObjRateLimit.py
Rate limiting and brute force protection for authentication.
Implements per-user and per-IP rate limiting with account lockout,
exponential backoff, and automatic recovery.
| Method | Signature | Description |
|---|---|---|
| is_login_allowed | is_login_allowed(username: str, package: str, ip_address: Optional[str] = None) -> Tuple[bool, Optional[str]] |
Check if login is allowed based on rate limiting. |
| record_login_attempt | record_login_attempt(username: str, package: str, ip_address: Optional[str], success: bool, session_id: Optional[str] = None, failure_reason: Optional[str] = None, user_agent: Optional[str] = None) |
Record a login attempt. |
| get_failed_attempts | get_failed_attempts(username: str, package: str, window_minutes: Optional[int] = None) -> int |
Get count of failed login attempts for user. |
| get_ip_failed_attempts | get_ip_failed_attempts(ip_address: str, window_minutes: Optional[int] = None) -> int |
Get count of failed login attempts for IP. |
| is_account_locked | is_account_locked(username: str, package: str) -> Tuple[bool, Optional[datetime]] |
Check if account is currently locked. |
| unlock_account | unlock_account(username: str, package: str) -> bool |
Manually unlock an account by clearing failed |
| unblock_ip | unblock_ip(ip_address: str) -> bool |
Manually unblock an IP address by clearing failed |
| cleanup_old_attempts | cleanup_old_attempts(older_than_days: int = 7) -> int |
Clean up old login attempt records. |
| get_recent_attempts | get_recent_attempts(username: Optional[str] = None, package: Optional[str] = None, ip_address: Optional[str] = None, limit: int = 100) -> list |
Get recent login attempts. |
| get_statistics | get_statistics(package: Optional[str] = None, hours: int = 24) -> Dict[str, Any] |
Get rate limiting statistics. |