fix(radius): 修复radius认证失败问题 (#4341)

* fix(radius): 修复radius认证失败问题,添加get_django_user方法参数(django-radius==1.4.0 中添加了额外参数)

* fix(radius): 修复radius认证失败问题,重写authenticate方法(django-radius 不接受public_key参数)
pull/4350/head
BaiJiangJie 2020-07-16 17:07:04 +08:00 committed by GitHub
parent e3dc76f281
commit 5c67f4311d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -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