aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/api/middleware.py
blob: bed7b542a24a336d1402c5833b4f95b9bb8b1ce2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
"""
Hub middleware — rate limiting on auth endpoints.

Uses slowapi (Starlette-compatible, token bucket algorithm).
Limits applied to /v1/users/register and /v1/users/login
to mitigate credential stuffing and registration floods.
"""

from slowapi import Limiter
from slowapi.util import get_remote_address

# Rate limiter instance — mounted on the FastAPI app in app.py
limiter = Limiter(key_func=get_remote_address)