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 = {
baseUrl: 'https://app.hehelucky.cn',
footer:{
copyright:'Copyright © 2017-2020 第九系艾文 版权所有.',
ipcBeiAn:{
url:'https://beian.miit.gov.cn',
text:'豫ICP备15004336号',
footer: {
copyright: 'Copyright © 2017-2020 第九系艾文 版权所有.',
ipcBeiAn: {
url: 'https://beian.miit.gov.cn',
text: '豫ICP备15004336号',
},
gongAnBeiAn:{
url:'http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=41142202000049',
text:'豫公网安备 41142202000049号',
gongAnBeiAn: {
url: 'http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=41142202000049',
text: '豫公网安备 41142202000049号',
},
}

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

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

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

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

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

@ -153,12 +153,14 @@ def get_api_obj(auth):
app_api_obj = None
return app_api_obj
def get_apple_udid_key(auth):
mpkey = auth.get("username")
if auth.get("issuer_id"):
mpkey = auth.get("issuer_id")
return mpkey
def get_http_server_doamin(request):
server_domain = SERVER_DOMAIN.get('POST_UDID_DOMAIN', None)
if not server_domain or not server_domain.startswith("http"):
@ -237,8 +239,9 @@ class IosUtils(object):
app_id = self.app_obj.app_id
device_udid = self.udid_info.get('udid')
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(),
self.auth)
return get_api_obj(self.auth).get_profile(bundleId, app_id, device_udid, device_name,
self.get_profile_full_path(),
self.auth)
def get_profile_full_path(self):
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 auth.get("issuer_id"):
cert_id = result.id
AppIOSDeveloperInfo.objects.filter(user_id=user_obj, issuer_id=auth.get("issuer_id")).update(is_actived=True,
certid=cert_id)
AppIOSDeveloperInfo.objects.filter(user_id=user_obj, issuer_id=auth.get("issuer_id")).update(
is_actived=True,
certid=cert_id)
else:
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:
cert_info = f.read()
except Exception as e:
logger.error("create_developer_cert developer_obj:%s user_obj:%s delete file failed Exception:%s" % (
developer_obj, user_obj, e))
logger.error(
"create_developer_cert developer_obj:%s user_obj:%s delete file failed Exception:%s" % (
developer_obj, user_obj, e))
if cert_info:
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,
certid=cert_id)
AppIOSDeveloperInfo.objects.filter(user_id=user_obj, email=auth.get("username")).update(
is_actived=True,
certid=cert_id)
return status, result
@staticmethod
@ -518,7 +524,8 @@ class IosUtils(object):
UDIDsyncDeveloper.objects.filter(developerid=developer_obj, platform=1).delete()
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:
device = {
"serial": formatdevice[0][0],
@ -527,7 +534,8 @@ class IosUtils(object):
"version": formatdevice[0][3],
"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:
pass
else:

@ -753,7 +753,7 @@ class AppStoreConnectApi(DevicesAPI, BundleIDsAPI, BundleIDsCapabilityAPI, Profi
def delete_bundle_by_identifier(self, 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)
if req.status_code == 204:
return True
@ -785,8 +785,7 @@ class AppStoreConnectApi(DevicesAPI, BundleIDsAPI, BundleIDsCapabilityAPI, Profi
return True
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:
return self.__certificates_store(req, 201)
raise KeyError(req.text)

@ -29,7 +29,7 @@ def file_format_path(user_obj, auth=None, email=None):
else:
pkey = auth.get("username")
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_path = os.path.join(SUPER_SIGN_ROOT, cert_dir_name)
if not os.path.isdir(cert_dir_path):

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

Loading…
Cancel
Save