[Update] 修改radius MFA

This commit is contained in:
ibuler
2019-11-11 20:10:49 +08:00
parent f53cf8d544
commit a01126c6c7
3 changed files with 33 additions and 1 deletions

View File

@@ -375,9 +375,20 @@ class MFAMixin:
self.otp_level = 0
self.otp_secret_key = None
def check_otp_on_radius(self, code):
from authentication.backends.radius import RadiusBackend
backend = RadiusBackend()
user = backend.authenticate(None, username=self.username, password=code)
if user:
return True
return False
def check_otp(self, code):
from ..utils import check_otp_code
return check_otp_code(self.otp_secret_key, code)
if settings.CONFIG.OTP_IN_RADIUS:
return self.check_otp_on_radius(code)
else:
return check_otp_code(self.otp_secret_key, code)
class User(AuthMixin, TokenMixin, RoleMixin, MFAMixin, AbstractUser):