From 0fca33d874ad17d4ad7c233ce823bb039e3f58fe Mon Sep 17 00:00:00 2001 From: BaiJiangJie <32935519+BaiJiangJie@users.noreply.github.com> Date: Thu, 16 Jul 2020 17:07:40 +0800 Subject: [PATCH] =?UTF-8?q?fix(radius):=20=E4=BF=AE=E5=A4=8Dradius?= =?UTF-8?q?=E8=AE=A4=E8=AF=81=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98=20(#4342?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(radius): 修复radius认证失败问题,添加get_django_user方法参数(django-radius==1.4.0 中添加了额外参数) * fix(radius): 修复radius认证失败问题,重写authenticate方法(django-radius 不接受public_key参数) --- apps/authentication/backends/radius.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/authentication/backends/radius.py b/apps/authentication/backends/radius.py index 2b193bbd0..6e39b2b79 100644 --- a/apps/authentication/backends/radius.py +++ b/apps/authentication/backends/radius.py @@ -11,7 +11,7 @@ User = get_user_model() class CreateUserMixin: - def get_django_user(self, username, password=None): + def get_django_user(self, username, password=None, *args, **kwargs): if isinstance(username, bytes): username = username.decode() try: @@ -27,6 +27,12 @@ class CreateUserMixin: user.save() return user + 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