mirror of https://github.com/jumpserver/jumpserver
fix(auth): 修复radius decode error的问题
parent
90f03dda62
commit
8ee7230ead
|
@ -1,11 +1,11 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
|
import traceback
|
||||||
|
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from radiusauth.backends import RADIUSBackend, RADIUSRealmBackend
|
from radiusauth.backends import RADIUSBackend, RADIUSRealmBackend
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from pyrad.packet import AccessRequest
|
|
||||||
|
|
||||||
User = get_user_model()
|
User = get_user_model()
|
||||||
|
|
||||||
|
@ -27,6 +27,17 @@ class CreateUserMixin:
|
||||||
user.save()
|
user.save()
|
||||||
return user
|
return user
|
||||||
|
|
||||||
|
def _perform_radius_auth(self, client, packet):
|
||||||
|
# TODO: 等待官方库修复这个BUG
|
||||||
|
try:
|
||||||
|
return super()._perform_radius_auth(client, packet)
|
||||||
|
except UnicodeError as e:
|
||||||
|
import sys
|
||||||
|
tb = ''.join(traceback.format_exception(*sys.exc_info(), limit=2, chain=False))
|
||||||
|
if tb.find("cl.decode") != -1:
|
||||||
|
return [], False, False
|
||||||
|
return None
|
||||||
|
|
||||||
def authenticate(self, *args, **kwargs):
|
def authenticate(self, *args, **kwargs):
|
||||||
# 校验用户时,会传入public_key参数,父类authentication中不接受public_key参数,所以要pop掉
|
# 校验用户时,会传入public_key参数,父类authentication中不接受public_key参数,所以要pop掉
|
||||||
# TODO:需要优化各backend的authenticate方法,django进行调用前会检测各authenticate的参数
|
# TODO:需要优化各backend的authenticate方法,django进行调用前会检测各authenticate的参数
|
||||||
|
|
Loading…
Reference in New Issue