• Aryan Noshirvnai's avatar
    Rate-limit /auth/login against brute force · 28e9ac64
    Aryan Noshirvnai authored
    Username/password login had zero rate limiting since it shipped - unlimited
    guesses against any account from anywhere. Adds a username column to the
    existing AuthAttempt table (migration d22ca64d291e) and reuses the same
    DB-backed approach already protecting /auth/telegram/request_code: 10
    attempts per account per 15 minutes, 100 per source per hour. Kept
    independent of the Telegram rate limit despite sharing a table - both
    _check_rate_limit and the new _check_login_rate_limit filter on their own
    column (phone_number.isnot(None) / username.isnot(None)) so hammering one
    endpoint never burns the other's budget.
    
    Verified live: 10 wrong-password attempts succeed with 401, the 11th (even
    with the correct password) gets 429; a telegram request_code call
    immediately after is unaffected.
    Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
    28e9ac64
d22ca64d291e_add_username_to_auth_attempts.py 860 Bytes