Unpin django-ratelimit (#31416)
* fix: fix ratelimit upgrade changes Co-authored-by: Awais Qureshi <awais.qureshi@arbisoft.com>
This commit is contained in:
committed by
GitHub
parent
11e07f06b4
commit
b01cf355a7
@@ -9,10 +9,10 @@ import json
|
||||
from django.conf import settings
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views.generic import View
|
||||
from django_ratelimit import ALL
|
||||
from django_ratelimit.decorators import ratelimit
|
||||
from edx_django_utils import monitoring as monitoring_utils
|
||||
from oauth2_provider import views as dot_views
|
||||
from ratelimit import ALL
|
||||
from ratelimit.decorators import ratelimit
|
||||
|
||||
from openedx.core.djangoapps.auth_exchange import views as auth_exchange_views
|
||||
from openedx.core.djangoapps.oauth_dispatch import adapters
|
||||
|
||||
@@ -22,13 +22,12 @@ from django.utils.translation import gettext as _
|
||||
from django.views.decorators.csrf import csrf_exempt, csrf_protect, ensure_csrf_cookie
|
||||
from django.views.decorators.debug import sensitive_post_parameters
|
||||
from django.views.decorators.http import require_http_methods
|
||||
from django_ratelimit.decorators import ratelimit
|
||||
from edx_django_utils.monitoring import set_custom_attribute
|
||||
from ratelimit.decorators import ratelimit
|
||||
from rest_framework.views import APIView
|
||||
|
||||
from openedx_events.learning.data import UserData, UserPersonalData
|
||||
from openedx_events.learning.signals import SESSION_LOGIN_COMPLETED
|
||||
from openedx_filters.learning.filters import StudentLoginRequested
|
||||
from rest_framework.views import APIView
|
||||
|
||||
from common.djangoapps import third_party_auth
|
||||
from common.djangoapps.edxmako.shortcuts import render_to_response
|
||||
@@ -46,6 +45,7 @@ from openedx.core.djangoapps.user_api import accounts
|
||||
from openedx.core.djangoapps.user_authn.config.waffle import ENABLE_LOGIN_USING_THIRDPARTY_AUTH_ONLY
|
||||
from openedx.core.djangoapps.user_authn.cookies import get_response_with_refreshed_jwt_cookies, set_logged_in_cookies
|
||||
from openedx.core.djangoapps.user_authn.exceptions import AuthFailedError, VulnerablePasswordError
|
||||
from openedx.core.djangoapps.user_authn.tasks import check_pwned_password_and_send_track_event
|
||||
from openedx.core.djangoapps.user_authn.toggles import (
|
||||
is_require_third_party_auth_enabled,
|
||||
should_redirect_to_authn_microfrontend
|
||||
@@ -53,7 +53,6 @@ from openedx.core.djangoapps.user_authn.toggles import (
|
||||
from openedx.core.djangoapps.user_authn.views.login_form import get_login_session_form
|
||||
from openedx.core.djangoapps.user_authn.views.password_reset import send_password_reset_email_for_user
|
||||
from openedx.core.djangoapps.user_authn.views.utils import API_V1, ENTERPRISE_ENROLLMENT_URL_REGEX, UUID4_REGEX
|
||||
from openedx.core.djangoapps.user_authn.tasks import check_pwned_password_and_send_track_event
|
||||
from openedx.core.djangoapps.util.user_messages import PageLevelMessages
|
||||
from openedx.core.djangolib.markup import HTML, Text
|
||||
from openedx.core.lib.api.view_utils import require_post_params # lint-amnesty, pylint: disable=unused-import
|
||||
@@ -492,11 +491,13 @@ def enterprise_selection_page(request, user, next_url):
|
||||
key='openedx.core.djangoapps.util.ratelimit.request_post_email_or_username',
|
||||
rate=settings.LOGISTRATION_PER_EMAIL_RATELIMIT_RATE,
|
||||
method='POST',
|
||||
block=False,
|
||||
) # lint-amnesty, pylint: disable=too-many-statements
|
||||
@ratelimit(
|
||||
key='openedx.core.djangoapps.util.ratelimit.real_ip',
|
||||
rate=settings.LOGISTRATION_RATELIMIT_RATE,
|
||||
method='POST',
|
||||
block=False,
|
||||
) # lint-amnesty, pylint: disable=too-many-statements
|
||||
def login_user(request, api_version='v1'): # pylint: disable=too-many-statements
|
||||
"""
|
||||
|
||||
@@ -12,7 +12,7 @@ from django.urls import reverse
|
||||
from django.utils.translation import gettext as _
|
||||
from django.views.decorators.csrf import ensure_csrf_cookie
|
||||
from django.views.decorators.http import require_http_methods
|
||||
from ratelimit.decorators import ratelimit
|
||||
from django_ratelimit.decorators import ratelimit
|
||||
|
||||
from common.djangoapps import third_party_auth
|
||||
from common.djangoapps.edxmako.shortcuts import render_to_response
|
||||
|
||||
@@ -24,7 +24,7 @@ from django.views.decorators.http import require_POST
|
||||
from edx_ace import ace
|
||||
from edx_ace.recipient import Recipient
|
||||
from eventtracking import tracker
|
||||
from ratelimit.decorators import ratelimit
|
||||
from django_ratelimit.decorators import ratelimit
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.throttling import AnonRateThrottle
|
||||
from rest_framework.views import APIView
|
||||
@@ -280,8 +280,8 @@ def request_password_change(email, is_secure):
|
||||
|
||||
@csrf_exempt
|
||||
@require_POST
|
||||
@ratelimit(key=POST_EMAIL_KEY, rate=settings.PASSWORD_RESET_EMAIL_RATE)
|
||||
@ratelimit(key=REAL_IP_KEY, rate=settings.PASSWORD_RESET_IP_RATE)
|
||||
@ratelimit(key=POST_EMAIL_KEY, rate=settings.PASSWORD_RESET_EMAIL_RATE, block=False)
|
||||
@ratelimit(key=REAL_IP_KEY, rate=settings.PASSWORD_RESET_IP_RATE, block=False)
|
||||
def password_reset(request):
|
||||
"""
|
||||
Attempts to send a password reset e-mail.
|
||||
@@ -574,8 +574,8 @@ def _get_user_from_email(email):
|
||||
|
||||
|
||||
@require_POST
|
||||
@ratelimit(key=POST_EMAIL_KEY, rate=settings.PASSWORD_RESET_EMAIL_RATE)
|
||||
@ratelimit(key=REAL_IP_KEY, rate=settings.PASSWORD_RESET_IP_RATE)
|
||||
@ratelimit(key=POST_EMAIL_KEY, rate=settings.PASSWORD_RESET_EMAIL_RATE, block=False)
|
||||
@ratelimit(key=REAL_IP_KEY, rate=settings.PASSWORD_RESET_IP_RATE, block=False)
|
||||
def password_change_request_handler(request):
|
||||
"""Handle password change requests originating from the account page.
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ from openedx_events.learning.data import UserData, UserPersonalData
|
||||
from openedx_events.learning.signals import STUDENT_REGISTRATION_COMPLETED
|
||||
from openedx_filters.learning.filters import StudentRegistrationRequested
|
||||
from pytz import UTC
|
||||
from ratelimit.decorators import ratelimit
|
||||
from django_ratelimit.decorators import ratelimit
|
||||
from requests import HTTPError
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.views import APIView
|
||||
@@ -545,7 +545,7 @@ class RegistrationView(APIView):
|
||||
content_type="application/json")
|
||||
|
||||
@method_decorator(csrf_exempt)
|
||||
@method_decorator(ratelimit(key=REAL_IP_KEY, rate=settings.REGISTRATION_RATELIMIT, method='POST'))
|
||||
@method_decorator(ratelimit(key=REAL_IP_KEY, rate=settings.REGISTRATION_RATELIMIT, method='POST', block=False))
|
||||
def post(self, request):
|
||||
"""Create the user's account.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user