Merge pull request #83 from steverecio/rate_limiting

Add DRF throttle scopes
This commit is contained in:
Michael 2020-06-03 18:39:22 -05:00 committed by GitHub
commit 9fdb513b5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -36,6 +36,7 @@ class RegisterView(CreateAPIView):
serializer_class = RegisterSerializer
permission_classes = register_permission_classes()
token_model = TokenModel
throttle_scope = 'dj_rest_auth'
@sensitive_post_parameters_m
def dispatch(self, *args, **kwargs):

View File

@ -40,6 +40,7 @@ class LoginView(GenericAPIView):
permission_classes = (AllowAny,)
serializer_class = LoginSerializer
token_model = TokenModel
throttle_scope = 'dj_rest_auth'
@sensitive_post_parameters_m
def dispatch(self, *args, **kwargs):
@ -115,6 +116,7 @@ class LogoutView(APIView):
Accepts/Returns nothing.
"""
permission_classes = (AllowAny,)
throttle_scope = 'dj_rest_auth'
def get(self, request, *args, **kwargs):
if getattr(settings, 'ACCOUNT_LOGOUT_ON_GET', False):
@ -217,6 +219,7 @@ class PasswordResetView(GenericAPIView):
"""
serializer_class = PasswordResetSerializer
permission_classes = (AllowAny,)
throttle_scope = 'dj_rest_auth'
def post(self, request, *args, **kwargs):
# Create a serializer with request.data
@ -242,6 +245,7 @@ class PasswordResetConfirmView(GenericAPIView):
"""
serializer_class = PasswordResetConfirmSerializer
permission_classes = (AllowAny,)
throttle_scope = 'dj_rest_auth'
@sensitive_post_parameters_m
def dispatch(self, *args, **kwargs):
@ -265,6 +269,7 @@ class PasswordChangeView(GenericAPIView):
"""
serializer_class = PasswordChangeSerializer
permission_classes = (IsAuthenticated,)
throttle_scope = 'dj_rest_auth'
@sensitive_post_parameters_m
def dispatch(self, *args, **kwargs):