add a new fun

super_signature
nineven 5 years ago
parent de4285a46a
commit 4e60166ecc
  1. 1
      fir_ser/api/models.py
  2. 41
      fir_ser/api/utils/app/supersignutils.py

@ -217,6 +217,7 @@ class APPSuperSignUsedInfo(models.Model):
user_id = models.ForeignKey(to="UserInfo",verbose_name="用户ID",on_delete=models.CASCADE)
app_id = models.ForeignKey(to="Apps", on_delete=models.CASCADE, verbose_name="属于哪个APP")
udid = models.ForeignKey(to="AppUDID",on_delete=models.CASCADE, verbose_name="所消耗的udid")
developerid = models.ForeignKey(to="AppIOSDeveloperInfo",on_delete=models.CASCADE, verbose_name="所使用苹果开发者账户")
created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
updated_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")
class Meta:

@ -4,13 +4,14 @@
# author: liuyu
# date: 2020/3/6
import uuid, xmltodict,os
import uuid, xmltodict, os, re
from fir_ser.settings import SUPER_SIGN_ROOT, MEDIA_ROOT, SERVER_DOMAIN
from api.utils.app.iossignapi import AppDeveloperApi, ResignApp
from api.models import APPSuperSignUsedInfo, AppUDID, AppIOSDeveloperInfo, AppReleaseInfo
from api.utils.app.randomstrings import make_app_uuid, make_from_user_uuid
from django.db.models import F
def udid_bytes_to_dict(xml_stream):
new_uuid_info = {}
try:
@ -89,6 +90,7 @@ def get_http_server_doamin(request):
server_domain = "%s://%s" % (protocol, HTTP_HOST)
return server_domain
def get_redirect_server_domain(request):
server_domain = SERVER_DOMAIN.get('REDIRECT_UDID_DOMAIN', None)
if not server_domain or not server_domain.startswith("http"):
@ -108,16 +110,30 @@ class IosUtils(object):
self.user_obj = app_obj.user_id
self.get_developer_auth()
def get_developer_auth(self):
developer_obj = AppIOSDeveloperInfo.objects.filter(user_id=self.user_obj,is_actived=True,use_number__lte=F("usable_number")).first()
developer_obj = AppIOSDeveloperInfo.objects.filter(user_id=self.user_obj, is_actived=True,
use_number__lte=F("usable_number")).first()
auth = {
"username": developer_obj.email,
"password": developer_obj.password,
"certid": developer_obj.certid
}
self.developer_obj = developer_obj
self.auth = auth
def create_cert(self):
app_api_obj = AppDeveloperApi(**self.auth)
app_api_obj.create_cert(self.user_obj)
file_format_path_name = self.file_format_path()
cert_info = None
try:
with open(file_format_path_name + '.info', "r") as f:
cert_info = f.read()
except Exception as e:
print(e)
cert_id = re.findall(r'.*\n\tid=(.*),.*', cert_info)[0].replace('"', '')
AppIOSDeveloperInfo.objects.filter(user_id=self.user_obj, email=self.auth.get("username")).first().update(
is_actived=True, certid=cert_id)
def download_profile(self):
app_api_obj = AppDeveloperApi(**self.auth)
@ -127,6 +143,14 @@ class IosUtils(object):
device_name = self.udid_info.get('product')
app_api_obj.get_profile(bundleId, app_id, device_udid, device_name, self.get_profile_full_path())
def file_format_path(self):
cert_dir_name = make_app_uuid(self.app_obj.user_id, self.auth.get("username"))
cert_dir_path = os.path.join(SUPER_SIGN_ROOT, cert_dir_name)
if not os.path.isdir(cert_dir_path):
os.makedirs(cert_dir_path)
file_format_path_name = os.path.join(cert_dir_path, cert_dir_name)
return file_format_path_name
def get_profile_full_path(self):
cert_dir_name = make_app_uuid(self.user_obj, self.auth.get("username"))
cert_dir_path = os.path.join(SUPER_SIGN_ROOT, cert_dir_name, "profile")
@ -139,12 +163,8 @@ class IosUtils(object):
if AppUDID.objects.filter(app_id=self.app_obj, udid=self.udid_info.get('udid')).first().is_signed:
return
self.download_profile()
cert_dir_name = make_app_uuid(self.app_obj.user_id,self.auth.get("username"))
cert_dir_path = os.path.join(SUPER_SIGN_ROOT,cert_dir_name)
if not os.path.isdir(cert_dir_path):
os.makedirs(cert_dir_path)
file_format_path_name = os.path.join(cert_dir_path,cert_dir_name)
file_format_path_name = self.file_format_path()
my_local_key = file_format_path_name + ".key"
app_dev_pem = file_format_path_name + ".pem"
ResignAppObj = ResignApp(my_local_key, app_dev_pem)
@ -162,3 +182,8 @@ class IosUtils(object):
"binary_file": random_file_name + ".ipa"
}
AppUDID.objects.filter(app_id=self.app_obj, udid=self.udid_info.get('udid')).update(**newdata)
APPSuperSignUsedInfo.objects.create(app_id=self.app_obj, user_id=self.user_obj, developerid=self.developer_obj,
udid=self.udid_info.get('udid'))
AppIOSDeveloperInfo.objects.filter(user_id=self.user_obj, is_actived=True,
use_number__lte=F("usable_number")).first().update(
use_number=self.developer_obj.use_number + 1)

Loading…
Cancel
Save