formcat code

super_sign_new
nineven 4 years ago
parent d7a3506230
commit 0d42223af2
  1. 16
      fir_client/public/config.js
  2. 22
      fir_client/src/components/FirSuperSignBase.vue
  3. 2
      fir_client/src/components/ShortDownload.vue
  4. 1
      fir_ser/api/migrations/0014_auto_20210129_1600.py
  5. 1
      fir_ser/api/migrations/0015_auto_20210129_1730.py
  6. 95
      fir_ser/api/utils/app/iossignapi.py
  7. 28
      fir_ser/api/utils/app/supersignutils.py
  8. 5
      fir_ser/api/utils/apple/appleapiv3.py
  9. 2
      fir_ser/api/utils/utils.py
  10. 2
      fir_ser/api/views/supersign.py

@ -1,14 +1,14 @@
window.g = { window.g = {
baseUrl: 'https://app.hehelucky.cn', baseUrl: 'https://app.hehelucky.cn',
footer:{ footer: {
copyright:'Copyright © 2017-2020 第九系艾文 版权所有.', copyright: 'Copyright © 2017-2020 第九系艾文 版权所有.',
ipcBeiAn:{ ipcBeiAn: {
url:'https://beian.miit.gov.cn', url: 'https://beian.miit.gov.cn',
text:'豫ICP备15004336号', text: '豫ICP备15004336号',
}, },
gongAnBeiAn:{ gongAnBeiAn: {
url:'http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=41142202000049', url: 'http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=41142202000049',
text:'豫公网安备 41142202000049号', text: '豫公网安备 41142202000049号',
}, },
} }

@ -500,9 +500,9 @@
}) })
}, },
syncdevices() { syncdevices() {
let data={"email": this.editdeveloperinfo.email, "act": "syncdevice"}; let data = {"email": this.editdeveloperinfo.email, "act": "syncdevice"};
if(this.editdeveloperinfo.issuer_id){ if (this.editdeveloperinfo.issuer_id) {
data={"issuer_id": this.editdeveloperinfo.issuer_id, "act": "syncdevice"}; data = {"issuer_id": this.editdeveloperinfo.issuer_id, "act": "syncdevice"};
} }
this.iosdeveloperFun({ this.iosdeveloperFun({
"methods": "PUT", "methods": "PUT",
@ -510,9 +510,9 @@
}); });
}, },
isocertcert() { isocertcert() {
let data={"email": this.editdeveloperinfo.email, "act": "ioscert"}; let data = {"email": this.editdeveloperinfo.email, "act": "ioscert"};
if(this.editdeveloperinfo.issuer_id){ if (this.editdeveloperinfo.issuer_id) {
data={"issuer_id": this.editdeveloperinfo.issuer_id, "act": "ioscert"}; data = {"issuer_id": this.editdeveloperinfo.issuer_id, "act": "ioscert"};
} }
this.iosdeveloperFun({ this.iosdeveloperFun({
"methods": "PUT", "methods": "PUT",
@ -531,11 +531,11 @@
} }
}, },
activedeveloperFun(developer, act) { activedeveloperFun(developer, act) {
if(developer.email){ if (developer.email) {
this.iosdeveloperFun({"methods": "PUT", "data": {"email": developer.email, "act": act}}); this.iosdeveloperFun({"methods": "PUT", "data": {"email": developer.email, "act": act}});
this.codeactiveVisible = true; this.codeactiveVisible = true;
this.authemail = developer.email; this.authemail = developer.email;
}else if(developer.issuer_id){ } else if (developer.issuer_id) {
this.iosdeveloperFun({"methods": "PUT", "data": {"issuer_id": developer.issuer_id, "act": act}}); this.iosdeveloperFun({"methods": "PUT", "data": {"issuer_id": developer.issuer_id, "act": act}});
this.codeactiveVisible = true; this.codeactiveVisible = true;
} }
@ -586,9 +586,9 @@
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
let data={"email": developer_info.email}; let data = {"email": developer_info.email};
if(developer_info.issuer_id){ if (developer_info.issuer_id) {
data={"issuer_id": developer_info.issuer_id}; data = {"issuer_id": developer_info.issuer_id};
} }
this.iosdeveloperFun({"methods": "DELETE", "data": data}); this.iosdeveloperFun({"methods": "DELETE", "data": data});
}).catch(() => { }).catch(() => {

@ -80,7 +80,7 @@
<div class="actions type-ios"> <div class="actions type-ios">
<div><p>正在安装请按 Home 键在桌面查看</p> <div><p>正在安装请按 Home 键在桌面查看</p>
<p v-if="!this.currentappinfo.issupersign && this.mcurrentappinfo.release_type!==1"> <p v-if="!this.currentappinfo.issupersign && this.mcurrentappinfo.release_type!==1">
<button @click="gomobileaction"> <button @click="gomobileaction">
<a icon="el-icon-loadings" type="primary" <a icon="el-icon-loadings" type="primary"
:underline="false"> :underline="false">
安装完成后,需立即信任 安装完成后,需立即信任

@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('api', '0013_auto_20210128_1815'), ('api', '0013_auto_20210128_1815'),
] ]

@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('api', '0014_auto_20210129_1600'), ('api', '0014_auto_20210129_1600'),
] ]

@ -11,10 +11,12 @@ import os
from api.utils.app.randomstrings import make_app_uuid from api.utils.app.randomstrings import make_app_uuid
import logging import logging
from api.utils.apple.appleapiv3 import AppStoreConnectApi from api.utils.apple.appleapiv3 import AppStoreConnectApi
logger = logging.getLogger(__file__) logger = logging.getLogger(__file__)
import base64 import base64
from OpenSSL.SSL import FILETYPE_PEM from OpenSSL.SSL import FILETYPE_PEM
from OpenSSL.crypto import (dump_certificate_request, dump_privatekey, PKey, TYPE_RSA, X509Req,dump_certificate) from OpenSSL.crypto import (dump_certificate_request, dump_privatekey, PKey, TYPE_RSA, X509Req, dump_certificate)
def exec_shell(cmd, remote=False, timeout=None): def exec_shell(cmd, remote=False, timeout=None):
if remote: if remote:
@ -73,7 +75,7 @@ class AppDeveloperApi(object):
self.cmd = self.cmd + " cert add '%s'" % (self.file_format_path_name(user_obj)) self.cmd = self.cmd + " cert add '%s'" % (self.file_format_path_name(user_obj))
return exec_shell(self.cmd) return exec_shell(self.cmd)
def get_profile(self, bundleId, app_id, device_udid, device_name, provisionName,auth=None): def get_profile(self, bundleId, app_id, device_udid, device_name, provisionName, auth=None):
self.cmd = self.cmd + " profile add '%s' '%s' '%s' '%s' '%s' '%s'" % ( self.cmd = self.cmd + " profile add '%s' '%s' '%s' '%s' '%s' '%s'" % (
bundleId, app_id, device_udid, device_name, self.certid, provisionName) bundleId, app_id, device_udid, device_name, self.certid, provisionName)
return exec_shell(self.cmd) return exec_shell(self.cmd)
@ -133,17 +135,17 @@ class AppDeveloperApiV2(object):
self.p8key = p8key self.p8key = p8key
self.certid = certid self.certid = certid
def active(self,user_obj): def active(self, user_obj):
result = {} result = {}
try: try:
apple_obj = AppStoreConnectApi(self.issuer_id, self.private_key_id, self.p8key) apple_obj = AppStoreConnectApi(self.issuer_id, self.private_key_id, self.p8key)
certificates = apple_obj.get_all_certificates() certificates = apple_obj.get_all_certificates()
logger.info("ios developer active result:%s" %certificates) logger.info("ios developer active result:%s" % certificates)
if len(certificates) > 0: if len(certificates) > 0:
return True, result return True, result
except Exception as e: except Exception as e:
logger.error("ios developer active Failed Exception:%s" % e) logger.error("ios developer active Failed Exception:%s" % e)
result['return_info'] = "%s" %e result['return_info'] = "%s" % e
return False, result return False, result
def file_format_path_name(self, user_obj): def file_format_path_name(self, user_obj):
@ -153,33 +155,33 @@ class AppDeveloperApiV2(object):
os.makedirs(cert_dir_path) os.makedirs(cert_dir_path)
return os.path.join(cert_dir_path, cert_dir_name) return os.path.join(cert_dir_path, cert_dir_name)
def make_csr_content(self,csr_file_path,private_key_path): def make_csr_content(self, csr_file_path, private_key_path):
# create public/private key # create public/private key
key = PKey() key = PKey()
key.generate_key(TYPE_RSA, 2048) key.generate_key(TYPE_RSA, 2048)
# Generate CSR # Generate CSR
req = X509Req() req = X509Req()
req.get_subject().CN = 'FLY APP' req.get_subject().CN = 'FLY APP'
req.get_subject().O = 'FLY APP Inc' req.get_subject().O = 'FLY APP Inc'
req.get_subject().OU = 'IT' req.get_subject().OU = 'IT'
req.get_subject().L = 'BJ' req.get_subject().L = 'BJ'
req.get_subject().ST = 'BJ' req.get_subject().ST = 'BJ'
req.get_subject().C = 'CN' req.get_subject().C = 'CN'
req.get_subject().emailAddress = 'fly@fly.com' req.get_subject().emailAddress = 'fly@fly.com'
req.set_pubkey(key) req.set_pubkey(key)
req.sign(key, 'sha256') req.sign(key, 'sha256')
csr_content = dump_certificate_request(FILETYPE_PEM, req) csr_content = dump_certificate_request(FILETYPE_PEM, req)
with open(csr_file_path, 'wb+') as f: with open(csr_file_path, 'wb+') as f:
f.write(csr_content) f.write(csr_content)
with open(private_key_path, 'wb+') as f: with open(private_key_path, 'wb+') as f:
f.write(dump_privatekey(FILETYPE_PEM, key)) f.write(dump_privatekey(FILETYPE_PEM, key))
return csr_content return csr_content
def make_pem(self,cer_content,pem_path): def make_pem(self, cer_content, pem_path):
cert = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_ASN1,cer_content) cert = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_ASN1, cer_content)
with open(pem_path, 'wb+') as f: with open(pem_path, 'wb+') as f:
f.write(dump_certificate(FILETYPE_PEM,cert)) f.write(dump_certificate(FILETYPE_PEM, cert))
def create_cert(self, user_obj): def create_cert(self, user_obj):
result = {} result = {}
@ -188,32 +190,32 @@ class AppDeveloperApiV2(object):
csr_path = self.file_format_path_name(user_obj) csr_path = self.file_format_path_name(user_obj)
if not os.path.isdir(os.path.dirname(csr_path)): if not os.path.isdir(os.path.dirname(csr_path)):
os.makedirs(os.path.dirname(csr_path)) os.makedirs(os.path.dirname(csr_path))
csr_content = self.make_csr_content(csr_path+".csr",csr_path+".key") csr_content = self.make_csr_content(csr_path + ".csr", csr_path + ".key")
certificates = apple_obj.create_certificate(csr_content.decode("utf-8")) certificates = apple_obj.create_certificate(csr_content.decode("utf-8"))
if certificates: if certificates:
n=base64.b64decode(certificates.certificateContent) n = base64.b64decode(certificates.certificateContent)
with open(csr_path+".cer",'wb') as f: with open(csr_path + ".cer", 'wb') as f:
f.write(n) f.write(n)
self.make_pem(n,csr_path+".pem") self.make_pem(n, csr_path + ".pem")
logger.info("ios developer create result:%s" % certificates.certificateContent) logger.info("ios developer create result:%s" % certificates.certificateContent)
return True, certificates return True, certificates
except Exception as e: except Exception as e:
logger.error("ios developer active Failed Exception:%s" % e) logger.error("ios developer active Failed Exception:%s" % e)
result['return_info'] = "%s" %e result['return_info'] = "%s" % e
return False, result return False, result
def get_profile(self, bundleId, app_id, device_udid, device_name, provisionName,auth): def get_profile(self, bundleId, app_id, device_udid, device_name, provisionName, auth):
result={} result = {}
try: try:
apple_obj = AppStoreConnectApi(self.issuer_id, self.private_key_id, self.p8key) apple_obj = AppStoreConnectApi(self.issuer_id, self.private_key_id, self.p8key)
bundle_obj = apple_obj.register_bundle_id_enable_capability(app_id,bundleId + app_id) bundle_obj = apple_obj.register_bundle_id_enable_capability(app_id, bundleId + app_id)
apple_obj.register_device(device_name,device_udid) apple_obj.register_device(device_name, device_udid)
profile_obj = apple_obj.create_profile(bundle_obj.id,auth.get('certid'),provisionName.split("/")[-1]) profile_obj = apple_obj.create_profile(bundle_obj.id, auth.get('certid'), provisionName.split("/")[-1])
if profile_obj: if profile_obj:
n=base64.b64decode(profile_obj.profileContent) n = base64.b64decode(profile_obj.profileContent)
if not os.path.isdir(os.path.basename(provisionName)): if not os.path.isdir(os.path.basename(provisionName)):
os.makedirs(os.path.basename(provisionName)) os.makedirs(os.path.basename(provisionName))
with open(provisionName,'wb') as f: with open(provisionName, 'wb') as f:
f.write(n) f.write(n)
return True, profile_obj.profileContent return True, profile_obj.profileContent
except Exception as e: except Exception as e:
@ -242,22 +244,21 @@ class AppDeveloperApiV2(object):
device_obj = apple_obj.enabled_device(device_udid) device_obj = apple_obj.enabled_device(device_udid)
else: else:
device_obj = apple_obj.disabled_device(device_udid) device_obj = apple_obj.disabled_device(device_udid)
logger.info("device_obj %s result:%s" %(device_obj,status)) logger.info("device_obj %s result:%s" % (device_obj, status))
if device_obj and device_obj.id: if device_obj and device_obj.id:
return True, result return True, result
except Exception as e: except Exception as e:
logger.error("ios developer set devices status Failed Exception:%s" % e) logger.error("ios developer set devices status Failed Exception:%s" % e)
result['return_info'] = "%s" %e result['return_info'] = "%s" % e
return False, result return False, result
def get_device(self, user_obj): def get_device(self, user_obj):
result = {} result = {}
try: try:
apple_obj = AppStoreConnectApi(self.issuer_id, self.private_key_id, self.p8key) apple_obj = AppStoreConnectApi(self.issuer_id, self.private_key_id, self.p8key)
devices_obj_list = apple_obj.get_all_devices() devices_obj_list = apple_obj.get_all_devices()
if devices_obj_list: if devices_obj_list:
return True,devices_obj_list return True, devices_obj_list
except Exception as e: except Exception as e:
logger.error("ios developer delete profile Failed Exception:%s" % e) logger.error("ios developer delete profile Failed Exception:%s" % e)
result['return_info'] = "%s" % e result['return_info'] = "%s" % e

@ -153,12 +153,14 @@ def get_api_obj(auth):
app_api_obj = None app_api_obj = None
return app_api_obj return app_api_obj
def get_apple_udid_key(auth): def get_apple_udid_key(auth):
mpkey = auth.get("username") mpkey = auth.get("username")
if auth.get("issuer_id"): if auth.get("issuer_id"):
mpkey = auth.get("issuer_id") mpkey = auth.get("issuer_id")
return mpkey return mpkey
def get_http_server_doamin(request): def get_http_server_doamin(request):
server_domain = SERVER_DOMAIN.get('POST_UDID_DOMAIN', None) server_domain = SERVER_DOMAIN.get('POST_UDID_DOMAIN', None)
if not server_domain or not server_domain.startswith("http"): if not server_domain or not server_domain.startswith("http"):
@ -237,8 +239,9 @@ class IosUtils(object):
app_id = self.app_obj.app_id app_id = self.app_obj.app_id
device_udid = self.udid_info.get('udid') device_udid = self.udid_info.get('udid')
device_name = self.udid_info.get('product') device_name = self.udid_info.get('product')
return get_api_obj(self.auth).get_profile(bundleId, app_id, device_udid, device_name, self.get_profile_full_path(), return get_api_obj(self.auth).get_profile(bundleId, app_id, device_udid, device_name,
self.auth) self.get_profile_full_path(),
self.auth)
def get_profile_full_path(self): def get_profile_full_path(self):
cert_dir_name = make_app_uuid(self.user_obj, get_apple_udid_key(self.auth)) cert_dir_name = make_app_uuid(self.user_obj, get_apple_udid_key(self.auth))
@ -465,8 +468,9 @@ class IosUtils(object):
if status: if status:
if auth.get("issuer_id"): if auth.get("issuer_id"):
cert_id = result.id cert_id = result.id
AppIOSDeveloperInfo.objects.filter(user_id=user_obj, issuer_id=auth.get("issuer_id")).update(is_actived=True, AppIOSDeveloperInfo.objects.filter(user_id=user_obj, issuer_id=auth.get("issuer_id")).update(
certid=cert_id) is_actived=True,
certid=cert_id)
else: else:
file_format_path_name = file_format_path(user_obj, auth) file_format_path_name = file_format_path(user_obj, auth)
@ -475,12 +479,14 @@ class IosUtils(object):
with open(file_format_path_name + '.info', "r") as f: with open(file_format_path_name + '.info', "r") as f:
cert_info = f.read() cert_info = f.read()
except Exception as e: except Exception as e:
logger.error("create_developer_cert developer_obj:%s user_obj:%s delete file failed Exception:%s" % ( logger.error(
developer_obj, user_obj, e)) "create_developer_cert developer_obj:%s user_obj:%s delete file failed Exception:%s" % (
developer_obj, user_obj, e))
if cert_info: if cert_info:
cert_id = re.findall(r'.*\n\tid=(.*),.*', cert_info)[0].replace('"', '') cert_id = re.findall(r'.*\n\tid=(.*),.*', cert_info)[0].replace('"', '')
AppIOSDeveloperInfo.objects.filter(user_id=user_obj, email=auth.get("username")).update(is_actived=True, AppIOSDeveloperInfo.objects.filter(user_id=user_obj, email=auth.get("username")).update(
certid=cert_id) is_actived=True,
certid=cert_id)
return status, result return status, result
@staticmethod @staticmethod
@ -518,7 +524,8 @@ class IosUtils(object):
UDIDsyncDeveloper.objects.filter(developerid=developer_obj, platform=1).delete() UDIDsyncDeveloper.objects.filter(developerid=developer_obj, platform=1).delete()
for devicestr in devices_info.split(">"): for devicestr in devices_info.split(">"):
formatdevice = re.findall(r'.*Device id="(.*)",.*name="(.*)",.*udid="(.*?)",.*model=(.*),.*', devicestr) formatdevice = re.findall(r'.*Device id="(.*)",.*name="(.*)",.*udid="(.*?)",.*model=(.*),.*',
devicestr)
if formatdevice: if formatdevice:
device = { device = {
"serial": formatdevice[0][0], "serial": formatdevice[0][0],
@ -527,7 +534,8 @@ class IosUtils(object):
"version": formatdevice[0][3], "version": formatdevice[0][3],
"platform": 1 "platform": 1
} }
app_udid_obj = UDIDsyncDeveloper.objects.filter(developerid=developer_obj, udid=device.get("udid")) app_udid_obj = UDIDsyncDeveloper.objects.filter(developerid=developer_obj,
udid=device.get("udid"))
if app_udid_obj: if app_udid_obj:
pass pass
else: else:

@ -753,7 +753,7 @@ class AppStoreConnectApi(DevicesAPI, BundleIDsAPI, BundleIDsCapabilityAPI, Profi
def delete_bundle_by_identifier(self, identifier): def delete_bundle_by_identifier(self, identifier):
identifier_obj = self.list_bundle_ids_by_identifier(identifier) identifier_obj = self.list_bundle_ids_by_identifier(identifier)
if isinstance(identifier_obj,BundleIds): if isinstance(identifier_obj, BundleIds):
req = self.delete_bundle_id_by_id(identifier_obj.id) req = self.delete_bundle_id_by_id(identifier_obj.id)
if req.status_code == 204: if req.status_code == 204:
return True return True
@ -785,8 +785,7 @@ class AppStoreConnectApi(DevicesAPI, BundleIDsAPI, BundleIDsCapabilityAPI, Profi
return True return True
def create_certificate(self, csr_content, certificate_type='IOS_DISTRIBUTION'): def create_certificate(self, csr_content, certificate_type='IOS_DISTRIBUTION'):
req = super().create_certificate(csr_content,certificate_type) req = super().create_certificate(csr_content, certificate_type)
if req.status_code == 201: if req.status_code == 201:
return self.__certificates_store(req, 201) return self.__certificates_store(req, 201)
raise KeyError(req.text) raise KeyError(req.text)

@ -29,7 +29,7 @@ def file_format_path(user_obj, auth=None, email=None):
else: else:
pkey = auth.get("username") pkey = auth.get("username")
if auth.get("issuer_id"): if auth.get("issuer_id"):
pkey= auth.get("issuer_id") pkey = auth.get("issuer_id")
cert_dir_name = make_app_uuid(user_obj, pkey) cert_dir_name = make_app_uuid(user_obj, pkey)
cert_dir_path = os.path.join(SUPER_SIGN_ROOT, cert_dir_name) cert_dir_path = os.path.join(SUPER_SIGN_ROOT, cert_dir_name)
if not os.path.isdir(cert_dir_path): if not os.path.isdir(cert_dir_path):

@ -96,7 +96,7 @@ class DeveloperView(APIView):
return self.get(request) return self.get(request)
else: else:
res.code = 1008 res.code = 1008
res.msg = result.get("return_info","未知错误") res.msg = result.get("return_info", "未知错误")
return Response(res.dict) return Response(res.dict)
elif act == "nowactive": elif act == "nowactive":
code = data.get("code", None) code = data.get("code", None)

Loading…
Cancel
Save