feat(throttling): add auth throttling and structured cooldown errors
This commit is contained in:
@@ -30,6 +30,12 @@ from apps.users.api.serializers import (
|
||||
UserProfileSerializer,
|
||||
UserSearchSerializer,
|
||||
)
|
||||
from apps.users.api.throttles import (
|
||||
OTPLoginThrottle,
|
||||
OTPSendBurstThrottle,
|
||||
OTPSendSustainedThrottle,
|
||||
PasswordLoginThrottle,
|
||||
)
|
||||
from apps.users.services.auth import (
|
||||
register_user_with_password,
|
||||
register_user_with_otp,
|
||||
@@ -91,6 +97,7 @@ class SendOTPView(APIView):
|
||||
+ password reset
|
||||
"""
|
||||
permission_classes = (AllowAny,)
|
||||
throttle_classes = [OTPSendBurstThrottle, OTPSendSustainedThrottle]
|
||||
|
||||
@extend_schema(request=SendOTPSerializer, responses=None)
|
||||
def post(self, request):
|
||||
@@ -107,6 +114,7 @@ class SendOTPView(APIView):
|
||||
|
||||
class LoginView(APIView):
|
||||
permission_classes = (AllowAny,)
|
||||
throttle_classes = [PasswordLoginThrottle]
|
||||
|
||||
@extend_schema(request=LoginSerializer, responses=TokenPairSerializer)
|
||||
def post(self, request):
|
||||
@@ -123,6 +131,7 @@ class LoginView(APIView):
|
||||
|
||||
class LoginOTPView(APIView):
|
||||
permission_classes = (AllowAny,)
|
||||
throttle_classes = [OTPLoginThrottle]
|
||||
|
||||
@extend_schema(request=LoginOtpSerializer, responses=TokenPairSerializer)
|
||||
def post(self, request):
|
||||
|
||||
Reference in New Issue
Block a user