Browse Source

HUE-9715 [Django Upgrade] [django-axes] 'django.contrib.auth.views' has no attribute 'login'

ayush.goyal 4 năm trước cách đây
mục cha
commit
65d5db3c9f

+ 2 - 2
apps/useradmin/src/useradmin/views.py

@@ -26,7 +26,7 @@ import json
 
 LOG = logging.getLogger(__name__)
 
-from axes.decorators import FAILURE_LIMIT, LOCK_OUT_AT_FAILURE
+from axes.conf import settings
 from axes.models import AccessAttempt
 from axes.utils import reset
 try:
@@ -198,7 +198,7 @@ def massage_groups_for_json(groups):
 
 def is_user_locked_out(username):
   attempts = AccessAttempt.objects.filter(username=username)
-  return any(attempt.failures_since_start >= FAILURE_LIMIT and LOCK_OUT_AT_FAILURE for attempt in attempts)
+  return any(attempt.failures_since_start >= settings.AXES_FAILURE_LIMIT and settings.AXES_LOCK_OUT_AT_FAILURE for attempt in attempts)
 
 
 def delete_user(request):

+ 1 - 1
desktop/core/requirements.txt

@@ -10,7 +10,7 @@ configobj==5.0.6
 cryptography==3.2
 django-auth-ldap==1.3.0
 Django==2.0.13 # Django 2 then 3?
-django-axes==2.2.0
+django-axes==4.5.4
 django_babel==0.6.2
 django-celery-beat==1.4.0
 django_celery_results==1.0.4

+ 2 - 2
desktop/core/src/desktop/auth/views.py

@@ -28,7 +28,7 @@ import logging
 import sys
 from datetime import datetime
 
-from axes.decorators import watch_login
+from axes.decorators import axes_dispatch
 import django.contrib.auth.views
 from django.core.exceptions import SuspiciousOperation
 from django.contrib.auth import login, get_backends, authenticate
@@ -100,7 +100,7 @@ def dt_login_old(request, from_modal=False):
 
 
 @login_notrequired
-@watch_login
+@axes_dispatch
 def dt_login(request, from_modal=False):
   if request.method == 'GET':
     redirect_to = request.GET.get('next', '/')

+ 4 - 0
desktop/core/src/desktop/settings.py

@@ -412,7 +412,11 @@ CACHES = {
         'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', # TODO: Parameterize here for all the caches
         'LOCATION': 'unique-hue'
     },
+    'axes_cache': {
+        'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
+    },
 }
+AXES_CACHE = 'axes_cache'
 CACHES_HIVE_DISCOVERY_KEY = 'hive_discovery'
 CACHES[CACHES_HIVE_DISCOVERY_KEY] = {
     'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',