Mejora de fromts
This commit is contained in:
20
backend/app/core/limiter.py
Normal file
20
backend/app/core/limiter.py
Normal file
@@ -0,0 +1,20 @@
|
||||
"""
|
||||
Rate Limiter - ServiceManagerWeb
|
||||
|
||||
Configura slowapi con Redis como storage backend.
|
||||
Respeta settings.RATE_LIMIT_ENABLED: si está desactivado usa memoria
|
||||
y el limiter queda en modo noop (enabled=False).
|
||||
"""
|
||||
|
||||
from slowapi import Limiter
|
||||
from slowapi.util import get_remote_address
|
||||
|
||||
from app.core.config import get_settings
|
||||
|
||||
settings = get_settings()
|
||||
|
||||
limiter = Limiter(
|
||||
key_func=get_remote_address,
|
||||
storage_uri=settings.REDIS_URL if settings.RATE_LIMIT_ENABLED else "memory://",
|
||||
enabled=settings.RATE_LIMIT_ENABLED,
|
||||
)
|
||||
Reference in New Issue
Block a user