Problem
The /api/v1/scan endpoint is publicly accessible and currently has no rate limiting. A malicious user could spam thousands of scan requests, incurring heavy compute costs and degrading service for real users.
Goal
Add per-user rate limiting to the scan endpoint using slowapi (a FastAPI-compatible rate limiter based on limits).
Acceptance Criteria
Implementation Reference
from slowapi import Limiter
from slowapi.util import get_remote_address
limiter = Limiter(key_func=get_user_id_or_ip)
@router.post('/scan')
@limiter.limit('10/minute')
async def scan(...):
...
Problem
The
/api/v1/scanendpoint is publicly accessible and currently has no rate limiting. A malicious user could spam thousands of scan requests, incurring heavy compute costs and degrading service for real users.Goal
Add per-user rate limiting to the scan endpoint using
slowapi(a FastAPI-compatible rate limiter based onlimits).Acceptance Criteria
slowapiadded tobackend/requirements.txtPOST /api/v1/scan: 10 requests per minute per authenticated user (keyed byuser_idfrom JWT)429 Too Many Requestsresponse:{ "error": "error.rateLimitExceeded", "retry_after": 60 }api.tshandles 429 gracefully — shows a toast: 'Scan limit reached. Please wait a moment.'backend/tests/test_rate_limit.pyImplementation Reference