30 lines
844 B
Python
30 lines
844 B
Python
"""
|
|
Кастомные throttle классы для rate limiting.
|
|
"""
|
|
|
|
from rest_framework.throttling import UserRateThrottle, AnonRateThrottle
|
|
|
|
|
|
class BurstRateThrottle(UserRateThrottle):
|
|
"""
|
|
Throttle для критичных endpoints (login, register, password reset).
|
|
Ограничение: 60 запросов в минуту.
|
|
"""
|
|
scope = 'burst'
|
|
|
|
|
|
class UploadRateThrottle(UserRateThrottle):
|
|
"""
|
|
Throttle для загрузки файлов.
|
|
Ограничение: 20 загрузок в час.
|
|
"""
|
|
scope = 'upload'
|
|
|
|
|
|
class StrictAnonRateThrottle(AnonRateThrottle):
|
|
"""
|
|
Строгий throttle для неавторизованных пользователей.
|
|
Используется для публичных endpoints.
|
|
"""
|
|
scope = 'anon'
|