证书导出功能优化

publicsignpoll
youngS 3 years ago
parent 7702fa5209
commit 2ee4352544
  1. 8
      fir_client/src/components/user/FirSuperSignBase.vue
  2. 4
      fir_client/src/components/user/FirUserStorage.vue
  3. 3
      fir_ser/api/models.py
  4. 3
      fir_ser/api/utils/app/iossignapi.py
  5. 9
      fir_ser/api/utils/app/supersignutils.py
  6. 57
      fir_ser/api/utils/daobase.py
  7. 18
      fir_ser/api/utils/serializer.py
  8. 5
      fir_ser/api/views/supersign.py

@ -501,10 +501,12 @@
>
</el-table-column>
<el-table-column
prop="product"
prop="version"
label="设备名称"
align="center"
width="100">
align="center">
<template slot-scope="scope">
{{scope.row.product}} {{scope.row.version}}
</template>
</el-table-column>
<el-table-column
width="100"

@ -121,10 +121,6 @@
<el-form-item label-width="110px" label="key">
<el-input :disabled='Sdisabled' v-model="storageinfo.access_key"/>
</el-form-item>
<!-- <el-form-item label-width="110px" label="secret">-->
<!-- <el-input :disabled='Sdisabled' v-model="storageinfo.secret_key"/>-->
<!-- </el-form-item>-->
<el-form-item label-width="110px" label="bucket_name">
<el-input :disabled='Sdisabled' v-model="storageinfo.bucket_name"/>
</el-form-item>

@ -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)

@ -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):

@ -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

@ -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

@ -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'):

@ -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'))

Loading…
Cancel
Save