mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-11-28 11:35:05 +01:00
Fixed default throttle class
This commit is contained in:
@@ -12,9 +12,10 @@ from drf_spectacular.utils import extend_schema
|
||||
from rest_framework import response, status
|
||||
from rest_framework_simplejwt import views as jwt_views
|
||||
from rest_framework_simplejwt.exceptions import InvalidToken, TokenError
|
||||
from rest_framework.throttling import ScopedRateThrottle
|
||||
from rest_framework.views import APIView
|
||||
|
||||
from modoboa.lib.throttle import UserDosThrottle
|
||||
from modoboa.lib.throttle import UserDosThrottleView
|
||||
from modoboa.core.password_hashers import get_password_hasher
|
||||
from modoboa.core.utils import check_for_updates
|
||||
from modoboa.parameters import tools as param_tools
|
||||
@@ -28,7 +29,8 @@ logger = logging.getLogger("modoboa.auth")
|
||||
|
||||
class TokenObtainPairView(jwt_views.TokenObtainPairView):
|
||||
"""We overwrite this view to deal with password scheme update."""
|
||||
|
||||
|
||||
throttle_classes = [ScopedRateThrottle]
|
||||
throttle_scope = "login"
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
@@ -87,7 +89,8 @@ class EmailPasswordResetView(APIView):
|
||||
"""
|
||||
An Api View which provides a method to request a password reset token based on an e-mail address.
|
||||
"""
|
||||
|
||||
|
||||
throttle_classes = [ScopedRateThrottle]
|
||||
throttle_scope = 'password_recovery_request'
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
@@ -126,6 +129,7 @@ class DefaultPasswordResetView(EmailPasswordResetView):
|
||||
class PasswordResetSmsTOTP(APIView):
|
||||
""" Check SMS Totp code. """
|
||||
|
||||
throttle_classes = [ScopedRateThrottle]
|
||||
throttle_scope = 'password_recovery_totp_check'
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
@@ -153,6 +157,7 @@ class PasswordResetSmsTOTP(APIView):
|
||||
class PasswordResetConfirmView(APIView):
|
||||
""" Get and set new user password. """
|
||||
|
||||
throttle_classes = [ScopedRateThrottle]
|
||||
throttle_scope = 'password_recovery_apply'
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
@@ -174,7 +179,7 @@ class PasswordResetConfirmView(APIView):
|
||||
class ComponentsInformationAPIView(APIView):
|
||||
"""Retrieve information about installed components."""
|
||||
|
||||
throttle_classes = [UserDosThrottle]
|
||||
throttle_classes = [UserDosThrottleView]
|
||||
|
||||
@extend_schema(responses=serializers.ModoboaComponentSerializer(many=True))
|
||||
def get(self, request, *args, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user