jira/apps/api/plane/authentication
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
..
adapter fix: resolve open CodeQL security alerts (#9505) 2026-07-29 20:28:09 +05:30
middleware chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
provider fix: resolve open CodeQL security alerts (#9505) 2026-07-29 20:28:09 +05:30
utils chore: remove posthog integration and analytics scaffold (#9634) 2026-08-24 21:07:34 +05:30
views [WEB-7946] fix: add rate limiting to email/password sign-in and sign-up endpoints (#9335) 2026-08-28 00:13:58 +05:30
__init__.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
apps.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
rate_limit.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
session.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30
urls.py chore: add copyright (#8584) 2026-01-27 13:54:22 +05:30