mirror of https://github.com/jumpserver/jumpserver
* fix(radius): 修复radius认证失败问题,添加get_django_user方法参数(django-radius==1.4.0 中添加了额外参数) * fix(radius): 修复radius认证失败问题,重写authenticate方法(django-radius 不接受public_key参数)pull/4357/head v2.1.0
parent
08fdc57543
commit
070af8c491
|
@ -11,7 +11,7 @@ User = get_user_model()
|
||||||
|
|
||||||
|
|
||||||
class CreateUserMixin:
|
class CreateUserMixin:
|
||||||
def get_django_user(self, username, password=None):
|
def get_django_user(self, username, password=None, *args, **kwargs):
|
||||||
if isinstance(username, bytes):
|
if isinstance(username, bytes):
|
||||||
username = username.decode()
|
username = username.decode()
|
||||||
try:
|
try:
|
||||||
|
@ -27,6 +27,12 @@ class CreateUserMixin:
|
||||||
user.save()
|
user.save()
|
||||||
return user
|
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):
|
class RadiusBackend(CreateUserMixin, RADIUSBackend):
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue