From 8913aacd1ec0fcaa7bbb3a437f8b8b76025ab8a2 Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 16 Sep 2020 10:52:50 +0800 Subject: [PATCH] =?UTF-8?q?fix(authentication):=20=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=90=8C=E6=97=B6=E5=BC=80=E5=90=AFradius,=20openid=E5=BC=95?= =?UTF-8?q?=E8=B5=B7=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/authentication/backends/radius.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/apps/authentication/backends/radius.py b/apps/authentication/backends/radius.py index 8edd2124c..c6ecd9e68 100644 --- a/apps/authentication/backends/radius.py +++ b/apps/authentication/backends/radius.py @@ -2,7 +2,7 @@ # import traceback -from django.contrib.auth import get_user_model +from django.contrib.auth import get_user_model, authenticate from radiusauth.backends import RADIUSBackend, RADIUSRealmBackend from django.conf import settings @@ -38,16 +38,12 @@ class CreateUserMixin: return [], False, False return None - def authenticate(self, *args, **kwargs): - # 校验用户时,会传入public_key参数,父类authentication中不接受public_key参数,所以要pop掉 - # TODO:需要优化各backend的authenticate方法,django进行调用前会检测各authenticate的参数 - kwargs.pop('public_key', None) - return super().authenticate(*args, **kwargs) - class RadiusBackend(CreateUserMixin, RADIUSBackend): - pass + def authenticate(self, request, username=None, password=None, **kwargs): + return super().authenticate(request, username=username, password=password) class RadiusRealmBackend(CreateUserMixin, RADIUSRealmBackend): - pass + def authenticate(self, request, username=None, password=None, realm=None, **kwargs): + return super().authenticate(request, username=username, password=password, realm=realm)