大版本更新,签名逻辑更改

dependabot/npm_and_yarn/fir_admin/url-parse-1.5.10
nineven 3 years ago
parent 9353abc8a9
commit cb841b5cf7
  1. 15
      fir_client/src/components/apps/FirAppInfossupersign.vue
  2. 32
      fir_ser/api/migrations/0034_auto_20220208_0941.py
  3. 7
      fir_ser/api/models.py
  4. 19
      fir_ser/api/utils/app/supersignutils.py
  5. 8
      fir_ser/api/utils/apple/appleapiv3.py
  6. 5
      fir_ser/api/utils/modelutils.py
  7. 2
      fir_ser/api/utils/serializer.py
  8. 2
      fir_ser/api/utils/storage/caches.py
  9. 35
      fir_ser/api/views/apps.py
  10. 10
      fir_ser/api/views/uploads.py

@ -38,6 +38,21 @@
</el-link>
</el-tooltip>
</el-form-item>
<el-form-item label="自动更新"
label-width="200px">
<el-switch
:disabled="supersign_disable"
v-model="currentapp.change_auto_sign"
active-color="#13ce66"
:active-value="true"
inactive-color="#ff4949"
:inactive-value="false"
@change="saveappinfo({change_auto_sign:currentapp.change_auto_sign})">
</el-switch>
<el-link :underline="false" style="margin-left: 20px">开启自动更新新包入库或签名相关数据更改系统将会自动更新签名包</el-link>
</el-form-item>
<el-form-item label="专属配置" label-width="200px">
<el-button :disabled="supersign_disable" @click="bindAppletoapp">配置专属苹果开发账户</el-button>
<el-link :disabled="supersign_disable" :underline="false" style="margin-left: 20px" @click="bindAppletoapp"> 拥有

@ -0,0 +1,32 @@
# Generated by Django 3.2.3 on 2022-02-08 09:41
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0033_appiosdeveloperinfo_auto_check'),
]
operations = [
migrations.RemoveField(
model_name='appudid',
name='is_download',
),
migrations.RemoveField(
model_name='appudid',
name='is_signed',
),
migrations.AddField(
model_name='apps',
name='change_auto_sign',
field=models.BooleanField(default=False, verbose_name='签名相关的数据更新自动签名'),
),
migrations.AddField(
model_name='appudid',
name='sign_status',
field=models.SmallIntegerField(
choices=[(0, '新设备入库准备'), (1, '设备ID已经注册'), (2, 'bundelid已经注册'), (3, '描述文件已经下载'), (4, '已经完成签名打包')],
default=0, verbose_name='签名状态'),
),
]

@ -137,6 +137,7 @@ class Apps(models.Model):
password = models.CharField(verbose_name="访问密码", blank=True, help_text='默认 没有密码', max_length=32)
isshow = models.BooleanField(verbose_name="下载页可见", default=True)
issupersign = models.BooleanField(verbose_name="是否超级签名包", default=False)
change_auto_sign = models.BooleanField(verbose_name="签名相关的数据更新自动签名", default=False)
supersign_type_choices = ((0, '普通权限'), (1, '推送权限,请上传adhoc包'), (2, 'network、vpn、推送权限,请上传adhoc包'), (3, '特殊权限'))
supersign_type = models.SmallIntegerField(choices=supersign_type_choices, default=1, verbose_name="签名类型")
new_bundle_id = models.CharField(max_length=64, blank=True, null=True, verbose_name="new_bundle_id",
@ -252,8 +253,10 @@ class AppUDID(models.Model):
iccid = models.CharField(max_length=64, verbose_name="型号", blank=True, null=True, )
created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
updated_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")
is_signed = models.BooleanField(verbose_name="是否完成签名打包", default=False)
is_download = models.BooleanField(verbose_name="描述文件是否已经下载", default=False)
# is_signed = models.BooleanField(verbose_name="是否完成签名打包", default=False)
# is_download = models.BooleanField(verbose_name="描述文件是否已经下载", default=False)
sign_status_choices = ((0, '新设备入库准备'), (1, '设备ID已经注册'), (2, 'bundelid已经注册'), (3, '描述文件已经下载'), (4, '已经完成签名打包'))
sign_status = models.SmallIntegerField(choices=sign_status_choices, default=0, verbose_name="签名状态")
class Meta:
verbose_name = '设备详情'

@ -380,8 +380,8 @@ def get_developer_obj_by_others(user_obj, udid, app_obj, read_only):
def check_sign_is_exists(user_obj, app_obj, udid, developer_obj, sign=True):
d_result = {'code': 0, 'msg': 'success'}
app_udid_obj = AppUDID.objects.filter(app_id=app_obj, udid__udid=udid, udid__developerid=developer_obj).first()
if app_udid_obj and app_udid_obj.is_download:
if app_udid_obj.is_signed:
if app_udid_obj and app_udid_obj.sign_status >= 3:
if app_udid_obj.sign_status == 4:
if check_ipa_is_latest_sign(app_obj, developer_obj):
d_result['msg'] = f'udid {udid} exists app_id {app_obj}'
logger.warning(d_result)
@ -527,7 +527,7 @@ class IosUtils(object):
if udid_list:
for udid in udid_list:
udid_obj = UDIDsyncDeveloper.objects.filter(developerid_id=developer_obj_id, udid=udid).first()
AppUDID.objects.filter(app_id=app_obj, udid=udid_obj).update(**{"is_signed": True})
AppUDID.objects.filter(app_id=app_obj, udid=udid_obj, sign_status=3).update(sign_status=4)
del_cache_response_by_short(app_obj.app_id)
return True
@ -606,8 +606,8 @@ class IosUtils(object):
# 2. DeveloperDevicesID 添加新应用-设备绑定信息数据
# 3. AppUDID 添加数据,该数据主要是为了记录使用,is_signed 判断是否已经签名成功
del udid_info['udid']
udid_info['is_signed'] = False
udid_info['is_download'] = False
udid_info['sign_status'] = 1
# udid_info['is_download'] = False
udid_obj, _ = AppUDID.objects.update_or_create(app_id=app_obj, udid=sync_device_obj,
defaults=udid_info)
@ -652,7 +652,7 @@ class IosUtils(object):
app_id=app_obj)
else:
return status, result
AppUDID.objects.filter(app_id=app_obj, udid__developerid_id=developer_obj, sign_status=1).update(sign_status=2)
return True, developer_app_id_obj
@staticmethod
@ -814,6 +814,9 @@ class IosUtils(object):
def run_sign(user_obj, app_obj, developer_obj, d_time, udid_list=None):
if udid_list is None:
udid_list = []
# app_udid_queryset = AppUDID.objects.filter(app_id=app_obj, udid__developerid=developer_obj).all()
for udid_obj in UDIDsyncDeveloper.objects.filter(appudid__app_id=app_obj, developerid=developer_obj).all():
udid_list.append(udid_obj.udid)
else:
new_did_list = []
for did_udid in udid_list:
@ -823,10 +826,10 @@ class IosUtils(object):
return True, True
else:
udid_list = new_did_list
udid_list = list(set(udid_list))
d_result = {'code': 0, 'msg': 'success'}
AppUDID.objects.filter(app_id=app_obj, udid__udid__in=udid_list,
udid__developerid=developer_obj).update(is_download=True)
udid__developerid=developer_obj, sign_status=2).update(sign_status=3)
start_time = time.time()
logger.info(f"app_id {app_obj} download profile success. time:{start_time - d_time}")
random_file_name = make_from_user_uuid(developer_obj.user_id.uid)

@ -903,7 +903,7 @@ class AppStoreConnectApi(DevicesAPI, BundleIDsAPI, BundleIDsCapabilityAPI, Profi
return True
return False
@call_function_try_attempts()
@call_function_try_attempts(try_attempts=2)
def enable_capability_by_s_type(self, bundle_id, s_type):
capability_list = get_capability(s_type)
if capability_list:
@ -915,16 +915,16 @@ class AppStoreConnectApi(DevicesAPI, BundleIDsAPI, BundleIDsCapabilityAPI, Profi
logger.warning(f"{bundle_id} enable_capability {capability} failed {req.content}")
return True
@call_function_try_attempts()
@call_function_try_attempts(try_attempts=1)
def disable_capability_by_s_type(self, bundle_id, s_type=len(capability_info) - 1):
capability_list = get_capability(s_type)
if capability_list:
for capability in capability_list:
req = super().disable_capability(bundle_id, capability)
if self.__do_success(req, 204):
logger.info(f"{bundle_id} enable_capability {capability} success")
logger.info(f"{bundle_id} disable_capability {capability} success")
else:
logger.warning(f"{bundle_id} enable_capability {capability} failed {req.content}")
logger.warning(f"{bundle_id} disable_capability {capability} failed {req.content}")
return True
def enable_push_vpn_capability(self, bundle_id):

@ -13,7 +13,8 @@ from django.db.models import Count, Sum, Q
from rest_framework.pagination import PageNumberPagination
from api.models import AppReleaseInfo, UserDomainInfo, DomainCnameInfo, UserAdDisplayInfo, RemoteClientInfo, \
AppIOSDeveloperInfo, IosDeveloperPublicPoolBill, APPToDeveloper, UserInfo, UDIDsyncDeveloper, IosDeveloperBill
AppIOSDeveloperInfo, IosDeveloperPublicPoolBill, APPToDeveloper, UserInfo, UDIDsyncDeveloper, IosDeveloperBill, \
AppUDID
from common.base.baseutils import get_server_domain_from_request, get_user_default_domain_name, get_real_ip_address, \
get_origin_domain_name, is_valid_phone
@ -225,6 +226,8 @@ def check_super_sign_permission(user_obj):
def check_ipa_is_latest_sign(app_obj, developer_obj=None):
if AppUDID.objects.filter(app_id=app_obj, udid__developerid=developer_obj, sign_status__lt=4).first():
return
release_obj = AppReleaseInfo.objects.filter(app_id=app_obj, is_master=True).first()
all_app_to_dev = APPToDeveloper.objects.filter(app_id=app_obj)
if developer_obj:

@ -512,7 +512,7 @@ class DeviceUDIDSerializer(serializers.ModelSerializer):
class Meta:
model = models.AppUDID
# depth = 1
exclude = ["updated_time", "is_signed"]
exclude = ["updated_time", "sign_status"]
bundle_name = serializers.CharField(source="app_id.name")
bundle_id = serializers.CharField(source="app_id.bundle_id")

@ -45,7 +45,7 @@ def get_download_url_by_cache(app_obj, filename, limit, isdownload=True, key='',
if app_obj.get('issupersign', None):
download_url_type = 'mobileconifg'
else:
appudid_obj = AppUDID.objects.filter(app_id_id=app_obj.get("pk"), udid__udid=udid, is_signed=True).last()
appudid_obj = AppUDID.objects.filter(app_id_id=app_obj.get("pk"), udid__udid=udid, sign_status=4).last()
if appudid_obj:
super_sign_obj = APPSuperSignUsedInfo.objects.filter(udid__udid__udid=udid,
app_id_id=app_obj.get("pk"),

@ -12,7 +12,7 @@ from rest_framework.response import Response
from rest_framework.views import APIView
from api.base_views import app_delete
from api.models import Apps, AppReleaseInfo, APPToDeveloper, UserInfo, AppScreenShot
from api.models import Apps, AppReleaseInfo, APPToDeveloper, UserInfo, AppScreenShot, AppUDID
from api.tasks import run_resign_task
from api.utils.app.supersignutils import IosUtils
from api.utils.auth import ExpiringTokenAuthentication
@ -229,13 +229,6 @@ class AppInfoView(APIView):
app_obj.wxredirect = data.get("wxredirect", app_obj.wxredirect)
update_fields.append("wxredirect")
if app_obj.type == 1 and data.get('issupersign', -1) != -1:
# 为啥注释掉,就是该udid已经在该平台使用了,虽然已经没有余额,但是其他应用也是可以超级签名的
# developer_obj = AppIOSDeveloperInfo.objects.filter(user_id=request.user)
# use_num = get_developer_devices(developer_obj)
# if use_num.get("flyapp_used_sum") >= use_num.get("all_usable_number"):
# res.code = 1008
# res.msg = "超级签余额不足,无法开启"
# return Response(res.dict)
if data.get('issupersign', -1) == 1 and not check_super_sign_permission(request.user):
logger.error(f"app_id:{app_id} can't open super_sign,owner has no ios developer")
res.code = 1008
@ -244,16 +237,36 @@ class AppInfoView(APIView):
do_sign_flag = 3
app_obj.issupersign = data.get("issupersign", app_obj.issupersign)
update_fields.append("issupersign")
if app_obj.issupersign and data.get('change_auto_sign', -1) != -1:
if data.get('change_auto_sign', -1) == 1:
do_sign_flag = 3
app_obj.change_auto_sign = data.get("change_auto_sign", app_obj.change_auto_sign)
update_fields.append("change_auto_sign")
logger.info(f"app_id:{app_id} update new data:{app_obj.__dict__}")
app_obj.save(update_fields=update_fields)
if app_obj.issupersign:
c_task = None
if do_sign_flag == 1:
c_task = run_resign_task(app_obj.pk, True)
AppUDID.objects.filter(app_id=app_obj).update(sign_status=2)
if app_obj.change_auto_sign:
c_task = run_resign_task(app_obj.pk, True)
if do_sign_flag == 2:
c_task = run_resign_task(app_obj.pk, False)
AppUDID.objects.filter(app_id=app_obj, sign_status__gte=3).update(sign_status=3)
if app_obj.change_auto_sign:
flag = False
if AppUDID.objects.filter(app_id=app_obj, sign_status=2).first():
flag = True
c_task = run_resign_task(app_obj.pk, flag)
if do_sign_flag == 3:
c_task = run_resign_task(app_obj.pk, False, False)
if app_obj.change_auto_sign:
flag = False
if AppUDID.objects.filter(app_id=app_obj, sign_status=2).first():
flag = True
c_task = run_resign_task(app_obj.pk, flag, False)
if c_task:
logger.info(f"app {app_obj} run_resign_task msg:{c_task}")
del_cache_response_by_short(app_obj.app_id)

@ -10,7 +10,7 @@ import os
from rest_framework.response import Response
from rest_framework.views import APIView
from api.models import Apps, AppReleaseInfo, UserInfo, AppScreenShot, CertificationInfo, UserAdDisplayInfo
from api.models import Apps, AppReleaseInfo, UserInfo, AppScreenShot, CertificationInfo, UserAdDisplayInfo, AppUDID
from api.tasks import run_resign_task
from api.utils.TokenManager import verify_token
from api.utils.app.apputils import get_random_short, save_app_infos
@ -139,10 +139,12 @@ class AppAnalyseView(APIView):
storage.rename_file(app_tmp_filename, app_new_filename)
storage.rename_file(png_tmp_filename, png_new_filename)
app_obj = Apps.objects.filter(bundle_id=data.get("bundleid"), user_id=request.user).first()
app_obj = Apps.objects.filter(bundle_id=data.get("bundleid"), user_id=request.user, type=4).first()
if app_obj:
c_task = run_resign_task(app_obj.pk, False, False)
logger.info(f"app {app_obj} run_resign_task end msg:{c_task}")
AppUDID.objects.filter(app_id=app_obj, sign_status__gte=3).update(sign_status=3)
if app_obj.change_auto_sign:
c_task = run_resign_task(app_obj.pk, False, False)
logger.info(f"app {app_obj} run_resign_task end msg:{c_task}")
else:
storage.delete_file(app_tmp_filename)
storage.delete_file(png_tmp_filename)

Loading…
Cancel
Save