Description
The application currently lacks protection against brute-force attacks or Denial of Service (DoS). Any user or bot can hit the login or registration endpoints indefinitely.
Proposed Fix
Integrate express-rate-limit as a middleware.
- Limit general API hits to 100 per 15 minutes.
- Limit Auth routes (Login/Register) to 5 attempts per 15 minutes.
Test Cases
- TC1 (Normal Usage): Send 10 requests to
/api/v1/users/login. Verify all receive 200 or 401 status codes.
- TC2 (Rate Limit Trigger): Send 100+ requests rapidly. Verify the server returns
429 Too Many Requests.
- TC3 (Reset logic): Wait for the limit duration (15 mins) and verify access is restored.
Description
The application currently lacks protection against brute-force attacks or Denial of Service (DoS). Any user or bot can hit the login or registration endpoints indefinitely.
Proposed Fix
Integrate
express-rate-limitas a middleware.Test Cases
/api/v1/users/login. Verify all receive200or401status codes.429 Too Many Requests.