From 2ee4352544d60d86471f4841d3ca58991d988d34 Mon Sep 17 00:00:00 2001 From: youngS Date: Thu, 4 Nov 2021 11:37:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=81=E4=B9=A6=E5=AF=BC=E5=87=BA=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/user/FirSuperSignBase.vue | 8 ++- .../src/components/user/FirUserStorage.vue | 4 -- fir_ser/api/models.py | 3 +- fir_ser/api/utils/app/iossignapi.py | 3 + fir_ser/api/utils/app/supersignutils.py | 9 ++- fir_ser/api/utils/daobase.py | 57 +++++++++++++++++++ fir_ser/api/utils/serializer.py | 18 +----- fir_ser/api/views/supersign.py | 5 +- 8 files changed, 75 insertions(+), 32 deletions(-) create mode 100644 fir_ser/api/utils/daobase.py diff --git a/fir_client/src/components/user/FirSuperSignBase.vue b/fir_client/src/components/user/FirSuperSignBase.vue index 8456e20..d81890c 100644 --- a/fir_client/src/components/user/FirSuperSignBase.vue +++ b/fir_client/src/components/user/FirSuperSignBase.vue @@ -501,10 +501,12 @@ > + align="center"> + - - - - diff --git a/fir_ser/api/models.py b/fir_ser/api/models.py index 01ed094..1f3b130 100644 --- a/fir_ser/api/models.py +++ b/fir_ser/api/models.py @@ -535,8 +535,9 @@ class IosDeveloperPublicPoolBill(models.Model): help_text="0 消费 1 充值 2 转账") number = models.IntegerField(verbose_name="消耗次数", default=1) app_info = models.JSONField(max_length=256, verbose_name="属于哪个APP", null=True, blank=True) - udid_info = models.JSONField(max_length=256, verbose_name="设备id信息", null=True, blank=True) udid = models.CharField(max_length=64, verbose_name="设备udid", null=True, blank=True) + product = models.CharField(max_length=64, verbose_name="设备udid", null=True, blank=True) + version = models.CharField(max_length=64, verbose_name="设备udid", null=True, blank=True) developer_info = models.JSONField(max_length=256, verbose_name="开发者信息", null=True, blank=True) udid_sync_info = models.ForeignKey(to="UDIDsyncDeveloper", on_delete=models.SET_NULL, verbose_name="关联同步设备信息", null=True, blank=True) diff --git a/fir_ser/api/utils/app/iossignapi.py b/fir_ser/api/utils/app/iossignapi.py index 4a55341..bdddb69 100644 --- a/fir_ser/api/utils/app/iossignapi.py +++ b/fir_ser/api/utils/app/iossignapi.py @@ -109,6 +109,9 @@ class ResignApp(object): result["err_info"] = e return False, result + def check_p12_exists(self): + return os.path.exists(self.app_dev_p12) + def write_cert(self): for file in [self.app_dev_p12, self.app_dev_p12 + '.pwd', self.my_local_key, self.app_dev_pem]: if os.path.exists(file): diff --git a/fir_ser/api/utils/app/supersignutils.py b/fir_ser/api/utils/app/supersignutils.py index 68037c5..84655d6 100644 --- a/fir_ser/api/utils/app/supersignutils.py +++ b/fir_ser/api/utils/app/supersignutils.py @@ -20,7 +20,7 @@ from api.utils.app.iossignapi import ResignApp, AppDeveloperApiV2 from api.utils.baseutils import file_format_path, delete_app_profile_file, get_profile_full_path, format_apple_date, \ get_format_time, make_app_uuid, make_from_user_uuid from api.utils.response import BaseResponse -from api.utils.serializer import BillAppInfoSerializer, BillDeveloperInfoSerializer, BillUdidInfoSerializer +from api.utils.serializer import BillAppInfoSerializer, BillDeveloperInfoSerializer from api.utils.storage.caches import del_cache_response_by_short, send_msg_over_limit, check_app_permission, \ consume_user_download_times_by_app_obj from api.utils.storage.storage import Storage @@ -456,10 +456,9 @@ class IosUtils(object): app_info=BillAppInfoSerializer(self.app_obj).data, developer_info=BillDeveloperInfoSerializer( self.developer_obj).data, - udid_info=BillUdidInfoSerializer(udid_obj).data, action=0, - number=1, udid_sync_info=udid_sync_info, - remote_addr=client_ip, - udid=self.udid + action=0, number=1, udid_sync_info=udid_sync_info, + remote_addr=client_ip, product=udid_sync_info.product, + udid=self.udid, version=udid_sync_info.version ) @staticmethod diff --git a/fir_ser/api/utils/daobase.py b/fir_ser/api/utils/daobase.py new file mode 100644 index 0000000..be5b555 --- /dev/null +++ b/fir_ser/api/utils/daobase.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +# -*- coding:utf-8 -*- +# project: 11月 +# author: NinEveN +# date: 2021/11/3 +from django.conf import settings +from django.db import models + +from api.utils.baseutils import AESCipher + + +class AESCharField(models.CharField): + + def __init__(self, *args, **kwargs): + if 'prefix' in kwargs: + self.prefix = kwargs['prefix'] + del kwargs['prefix'] + else: + self.prefix = "aes:::" + self.cipher = AESCipher(settings.SECRET_KEY) + super(AESCharField, self).__init__(*args, **kwargs) + + def deconstruct(self): + name, path, args, kwargs = super(AESCharField, self).deconstruct() + if self.prefix != "aes:::": + kwargs['prefix'] = self.prefix + return name, path, args, kwargs + + def from_db_value(self, value, *args, **kwargs): + if value is None: + return value + if value.startswith(self.prefix): + value = value[len(self.prefix):] + if isinstance(value, str): + value = value.encode('utf-8') + value = self.cipher.decrypt(value) + return value + + def to_python(self, value): + if value is None: + return value + elif value.startswith(self.prefix): + value = value[len(self.prefix):] + if isinstance(value, str): + value = value.encode('utf-8') + value = self.cipher.decrypt(value) + return value + + def get_prep_value(self, value): + if isinstance(value, str): + value = value.encode('utf-8') + if isinstance(value, bytes): + value = self.cipher.encrypt(value) + value = self.prefix + value.decode('utf-8') + elif value is not None: + raise TypeError(str(value) + " is not a valid value for AESCharField") + return value diff --git a/fir_ser/api/utils/serializer.py b/fir_ser/api/utils/serializer.py index 0333cbf..c0aeb3e 100644 --- a/fir_ser/api/utils/serializer.py +++ b/fir_ser/api/utils/serializer.py @@ -739,24 +739,12 @@ class BillDeveloperInfoSerializer(serializers.ModelSerializer): fields = ["pk", "issuer_id", "user_id", "certid"] -class BillUdidInfoSerializer(serializers.ModelSerializer): - class Meta: - model = models.AppUDID - fields = ["pk", "app_id", "udid", "product", "serial", "version", "imei", "iccid"] - - udid = serializers.SerializerMethodField() - - def get_udid(self, obj): - return obj.udid.udid - - class BillInfoSerializer(serializers.ModelSerializer): class Meta: model = models.IosDeveloperPublicPoolBill exclude = ["user_id", "to_user_id", "developer_info", "app_info", "udid_sync_info"] app_name = serializers.SerializerMethodField() - product = serializers.SerializerMethodField() action = serializers.SerializerMethodField() description = serializers.SerializerMethodField() is_used = serializers.SerializerMethodField() @@ -775,12 +763,8 @@ class BillInfoSerializer(serializers.ModelSerializer): elif obj.to_user_id: return obj.user_id.first_name - def get_product(self, obj): - if obj.udid_info: - return obj.udid_info.get('product') - def get_description(self, obj): - if obj.udid_info: + if obj.udid: return f"{self.get_app_name(obj)}-{self.get_action(obj)} -{obj.number} 设备数" if obj.to_user_id: if obj.to_user_id == self.context.get('user_obj'): diff --git a/fir_ser/api/views/supersign.py b/fir_ser/api/views/supersign.py index 7584312..49ccd8c 100644 --- a/fir_ser/api/views/supersign.py +++ b/fir_ser/api/views/supersign.py @@ -274,8 +274,9 @@ class SuperSignCertView(APIView): issuer_id = request.query_params.get('issuer_id', None) if issuer_id: developer_obj = AppIOSDeveloperInfo.objects.filter(user_id=request.user, issuer_id=issuer_id).first() - # resign_app_obj = IosUtils.get_resign_obj(request.user, developer_obj) - # resign_app_obj.make_p12_from_cert(developer_obj.certid) + resign_app_obj = IosUtils.get_resign_obj(request.user, developer_obj) + if not resign_app_obj.check_p12_exists(): + resign_app_obj.make_p12_from_cert(developer_obj.certid) if developer_obj: zip_file_path = IosUtils.zip_cert(request.user, developer_obj) response = FileResponse(open(zip_file_path, 'rb'))