From 86d56234372256c1f192ca9b77e4ebb8e6062e71 Mon Sep 17 00:00:00 2001 From: youngS Date: Sat, 26 Jun 2021 11:49:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9p12=20=E8=AF=81=E4=B9=A6?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/user/FirSuperSignBase.vue | 2 +- fir_ser/api/utils/app/iossignapi.py | 15 +++++++++++++++ fir_ser/api/utils/app/supersignutils.py | 11 +++++++++++ fir_ser/api/views/supersign.py | 12 +++--------- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/fir_client/src/components/user/FirSuperSignBase.vue b/fir_client/src/components/user/FirSuperSignBase.vue index 1df8175..d6c2704 100644 --- a/fir_client/src/components/user/FirSuperSignBase.vue +++ b/fir_client/src/components/user/FirSuperSignBase.vue @@ -147,7 +147,7 @@ diff --git a/fir_ser/api/utils/app/iossignapi.py b/fir_ser/api/utils/app/iossignapi.py index 2083d19..8fe6282 100644 --- a/fir_ser/api/utils/app/iossignapi.py +++ b/fir_ser/api/utils/app/iossignapi.py @@ -202,6 +202,21 @@ class AppDeveloperApiV2(object): result['return_info'] = "%s" % e return False, result + def get_cert_obj_by_cid(self, cert_id): + result = {} + try: + apple_obj = AppStoreConnectApi(self.issuer_id, self.private_key_id, self.p8key) + cert_obj = apple_obj.get_certificate_by_cid(cert_id) + if cert_obj and cert_obj.id: + return True, result + else: + logger.info("ios developer get cert %s failed" % cert_id) + return False, result + except Exception as e: + logger.error("ios developer get cert %s Failed Exception:%s" % (cert_id, e)) + result['return_info'] = "%s" % e + return False, result + def revoke_cert(self, cert_id): result = {} try: diff --git a/fir_ser/api/utils/app/supersignutils.py b/fir_ser/api/utils/app/supersignutils.py index 1e7bf0a..97363a7 100644 --- a/fir_ser/api/utils/app/supersignutils.py +++ b/fir_ser/api/utils/app/supersignutils.py @@ -737,6 +737,17 @@ class IosUtils(object): certid=None, cert_expire_time=None) return status, result + @staticmethod + def check_developer_cert(developer_obj,user_obj): + auth = get_auth_form_developer(developer_obj) + app_api_obj = get_api_obj(auth) + status, result = app_api_obj.get_cert_obj_by_cid(developer_obj.certid) + if not status: + AppIOSDeveloperInfo.objects.filter(user_id=user_obj, issuer_id=auth.get("issuer_id")).update( + certid=None, cert_expire_time=None) + return status, result + + @staticmethod def auto_get_certid_by_p12(developer_obj, user_obj): auth = get_auth_form_developer(developer_obj) diff --git a/fir_ser/api/views/supersign.py b/fir_ser/api/views/supersign.py index a65dc5d..dcf8bc6 100644 --- a/fir_ser/api/views/supersign.py +++ b/fir_ser/api/views/supersign.py @@ -67,11 +67,13 @@ class DeveloperView(APIView): if act: res = BaseResponse() logger.info("user %s iosdeveloper %s act %s" % (request.user, developer_obj, act)) - if act == "preactive": + if act == "checkauth": status, result = IosUtils.active_developer(developer_obj) if status: if not developer_obj.certid: IosUtils.get_device_from_developer(developer_obj, request.user) + else: + IosUtils.check_developer_cert(developer_obj, request.user) return self.get(request) else: res.code = 1008 @@ -111,14 +113,6 @@ class DeveloperView(APIView): res.code = 1008 res.msg = result.get("err_info") return Response(res.dict) - elif act == "checkauth": - status, result = IosUtils.active_developer(developer_obj) - if status: - return self.get(request) - else: - res.code = 1008 - res.msg = result.get("return_info") - return Response(res.dict) else: logger.info("user %s iosdeveloper %s update input data %s" % (request.user, developer_obj, data)) logger.info("user %s iosdeveloper %s update old data %s" % (