From 0a74602df31578ef31c780c963b5701e87970314 Mon Sep 17 00:00:00 2001 From: BaiJiangJie Date: Wed, 13 Nov 2019 15:08:54 +0800 Subject: [PATCH 1/4] =?UTF-8?q?[Update]=20=E4=BF=AE=E6=94=B9=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=20LDAP=20=E5=90=8C=E6=AD=A5=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=9C=A8=E4=BB=BB=E5=8A=A1=E5=A4=96=E9=83=A8=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?running=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/settings/api.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/settings/api.py b/apps/settings/api.py index f55b37749..1fce9a44d 100644 --- a/apps/settings/api.py +++ b/apps/settings/api.py @@ -186,6 +186,8 @@ class LDAPUserListApi(generics.ListAPIView): sync_util = LDAPSyncUtil() # 还没有同步任务 if sync_util.task_no_start: + # 任务外部设置 task running 状态 + sync_util.set_task_status(sync_util.TASK_STATUS_IS_RUNNING) task = sync_ldap_user_task.delay() data = {'msg': 'Cache no data, sync task {} started.'.format(task.id)} return Response(data=data, status=409) From 4b2fbbfb84c3882bc0d909642bbe79fb50570c88 Mon Sep 17 00:00:00 2001 From: BaiJiangJie Date: Wed, 13 Nov 2019 18:44:59 +0800 Subject: [PATCH 2/4] =?UTF-8?q?[Update]=20=E6=B7=BB=E5=8A=A0=20MFA=20Radiu?= =?UTF-8?q?s=20py-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)) From 870e04feac7eabd9b30ce8da84ee10f670d970d1 Mon Sep 17 00:00:00 2001 From: BaiJiangJie Date: Wed, 13 Nov 2019 18:46:22 +0800 Subject: [PATCH 3/4] =?UTF-8?q?[Update]=20=E6=B7=BB=E5=8A=A0=20py-radius?= =?UTF-8?q?=20=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements/requirements.txt b/requirements/requirements.txt index d99c6ee27..c43046d3c 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -89,3 +89,4 @@ flower==0.9.3 channels-redis==2.4.0 channels==2.3.0 daphne==2.3.0 +py-radius==2.0.2.post1 From aebf32d7be303527175624f06f5a2a2d4bbb3d48 Mon Sep 17 00:00:00 2001 From: BaiJiangJie Date: Thu, 14 Nov 2019 10:56:29 +0800 Subject: [PATCH 4/4] =?UTF-8?q?[Update]=20=E5=88=A0=E9=99=A4=20py-radius?= =?UTF-8?q?=20=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/authentication/backends/radius.py | 31 -------------------------- requirements/requirements.txt | 1 - 2 files changed, 32 deletions(-) diff --git a/apps/authentication/backends/radius.py b/apps/authentication/backends/radius.py index 9e0f7167b..47f369205 100644 --- a/apps/authentication/backends/radius.py +++ b/apps/authentication/backends/radius.py @@ -51,34 +51,3 @@ 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)) diff --git a/requirements/requirements.txt b/requirements/requirements.txt index c43046d3c..d99c6ee27 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -89,4 +89,3 @@ flower==0.9.3 channels-redis==2.4.0 channels==2.3.0 daphne==2.3.0 -py-radius==2.0.2.post1