jira/apps/api/plane/authentication/views/space
Manish Gupta e30605d419
[WEB-7946] fix: add rate limiting to email/password sign-in and sign-up endpoints (#9335)
* fix: add rate limiting to email/password sign-in and sign-up endpoints

All four password authentication views (app sign-in, app sign-up, space
sign-in, space sign-up) extended django.views.View, so DRF's global
AnonRateThrottle never ran and the endpoints accepted unlimited credential
guesses with no friction (brute-force / credential stuffing, GHSA-349j).

Add authentication_throttle_allows(request) at the top of each post()
method — before any DB access — using the same AuthenticationThrottle
already guarding the magic-code views. On rejection the view redirects with
RATE_LIMIT_EXCEEDED, consistent with all other throttled auth endpoints.
Default limit remains 10/minute, overridable via AUTHENTICATION_RATE_LIMIT.

Co-authored-by: Plane AI <noreply@plane.so>

* refactor: consolidate auth throttle into a decorator + add tests

- Extract the repeated throttle-and-redirect block from the six redirect-flow
  auth views (email + magic, app + space) into a single throttle_auth_redirect
  decorator in rate_limit.py. Behaviour is unchanged: the throttle still runs
  before any DB access; brute-force traffic is rejected without a DB hit.
- Add regression tests for the password sign-in/sign-up throttle on both app
  and space endpoints, mirroring the existing magic-code throttle tests.
- Reset the shared AuthenticationThrottle bucket before every test in
  test_authentication.py. All auth endpoints share one per-IP throttle scope,
  so the newly-throttled password requests exhausted the budget mid-file and
  caused unrelated tests to trip RATE_LIMIT_EXCEEDED.

---------

Co-authored-by: Plane AI <noreply@plane.so>
Co-authored-by: sriramveeraghanta <veeraghanta.sriram@gmail.com>
2026-08-28 00:13:58 +05:30
..
check.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
email.py [WEB-7946] fix: add rate limiting to email/password sign-in and sign-up endpoints (#9335) 2026-08-28 00:13:58 +05:30
gitea.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
github.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
gitlab.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
google.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
magic.py [WEB-7946] fix: add rate limiting to email/password sign-in and sign-up endpoints (#9335) 2026-08-28 00:13:58 +05:30
password_management.py [GIT-44] refactor(auth): add PASSWORD_TOO_WEAK error code (#8522) 2026-02-13 18:51:33 +05:30
signout.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30