From 4b2fbbfb84c3882bc0d909642bbe79fb50570c88 Mon Sep 17 00:00:00 2001 From: BaiJiangJie Date: Wed, 13 Nov 2019 18:44:59 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E6=B7=BB=E5=8A=A0=20MFA=20Radius=20?= =?UTF-8?q?py-radius=20=E6=B5=8B=E8=AF=95=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/authentication/backends/radius.py | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/apps/authentication/backends/radius.py b/apps/authentication/backends/radius.py index 47f369205..9e0f7167b 100644 --- a/apps/authentication/backends/radius.py +++ b/apps/authentication/backends/radius.py @@ -51,3 +51,34 @@ class RadiusBackend(CreateUserMixin, RADIUSBackend): class RadiusRealmBackend(CreateUserMixin, RADIUSRealmBackend): pass + + +class TestRadiusPyRadius(object): + + def __init__(self, username, password): + self.username = username + self.password = password + self.secret = settings.CONFIG.RADIUS_SECRET + self.host = settings.CONFIG.RADIUS_SERVER + self.port = settings.CONFIG.RADIUS_PORT + + def attr_to_json(self): + attr_json = { + 'username': self.username, + 'password': self.password, + 'secret': self.secret, + 'host': self.host, + 'port': self.port + } + return attr_json + + def authenticate(self): + import radius + print('Authenticate Radius start: ') + params = self.attr_to_json() + print("Params: {}".format(params)) + r = radius.authenticate( + self.username, self.password, + self.secret, host=self.host, port=int(self.port) + ) + print("Result: {}".format(r))