mirror of https://github.com/certd/certd
chore:
parent
81b322cd60
commit
ab5c7bb75a
|
@ -249,6 +249,9 @@ export class AcmeService {
|
||||||
const httpVerifyPlan = domainVerifyPlan.httpVerifyPlan;
|
const httpVerifyPlan = domainVerifyPlan.httpVerifyPlan;
|
||||||
if (httpVerifyPlan) {
|
if (httpVerifyPlan) {
|
||||||
const httpChallenge = getChallenge("http-01");
|
const httpChallenge = getChallenge("http-01");
|
||||||
|
if (httpChallenge == null) {
|
||||||
|
throw new Error("该域名不支持http-01方式校验");
|
||||||
|
}
|
||||||
const plan = httpVerifyPlan[fullDomain];
|
const plan = httpVerifyPlan[fullDomain];
|
||||||
return await doHttpVerify(httpChallenge, plan.httpUploader);
|
return await doHttpVerify(httpChallenge, plan.httpUploader);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -17,6 +17,7 @@ export abstract class CertApplyBasePlugin extends AbstractTaskPlugin {
|
||||||
vModel: "value",
|
vModel: "value",
|
||||||
mode: "tags",
|
mode: "tags",
|
||||||
open: false,
|
open: false,
|
||||||
|
placeholder: "foo.com / *.foo.com / *.bar.com",
|
||||||
tokenSeparators: [",", " ", ",", "、", "|"],
|
tokenSeparators: [",", " ", ",", "、", "|"],
|
||||||
},
|
},
|
||||||
rules: [{ type: "domains" }],
|
rules: [{ type: "domains" }],
|
||||||
|
@ -26,9 +27,9 @@ export abstract class CertApplyBasePlugin extends AbstractTaskPlugin {
|
||||||
},
|
},
|
||||||
order: -999,
|
order: -999,
|
||||||
helper:
|
helper:
|
||||||
"1、支持通配符域名,例如: *.foo.com、foo.com、*.test.handsfree.work\n" +
|
"1、支持多个域名打到一个证书上,例如: foo.com,*.foo.com,*.bar.com\n" +
|
||||||
"2、支持多个域名、多个子域名、多个通配符域名打到一个证书上(域名必须是在同一个DNS提供商解析)\n" +
|
"2、子域名被通配符包含的不要填写,例如:www.foo.com已经被*.foo.com包含,不要填写www.foo.com\n" +
|
||||||
"3、多级子域名要分成多个域名输入(*.foo.com的证书不能用于xxx.yyy.foo.com、foo.com)\n" +
|
"3、泛域名只能通配*号那一级(*.foo.com的证书不能用于xxx.yyy.foo.com、不能用于foo.com)\n" +
|
||||||
"4、输入一个,空格之后,再输入下一个",
|
"4、输入一个,空格之后,再输入下一个",
|
||||||
})
|
})
|
||||||
domains!: string[];
|
domains!: string[];
|
||||||
|
|
|
@ -9,6 +9,12 @@ export type CnameRecord = {
|
||||||
recordValue?: string;
|
recordValue?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type DomainGroupItem = {
|
||||||
|
domain: string;
|
||||||
|
domains?: string[];
|
||||||
|
keySubDomains?: string[];
|
||||||
|
};
|
||||||
|
|
||||||
export async function GetList() {
|
export async function GetList() {
|
||||||
return await request({
|
return await request({
|
||||||
url: apiPrefix + "/list",
|
url: apiPrefix + "/list",
|
||||||
|
|
|
@ -52,7 +52,6 @@ watch(
|
||||||
},
|
},
|
||||||
(value: any) => {
|
(value: any) => {
|
||||||
if (value) {
|
if (value) {
|
||||||
debugger;
|
|
||||||
records.value = {
|
records.value = {
|
||||||
...value
|
...value
|
||||||
};
|
};
|
||||||
|
|
|
@ -80,10 +80,11 @@ import { dict, FsDictSelect } from "@fast-crud/fast-crud";
|
||||||
import AccessSelector from "/@/views/certd/access/access-selector/index.vue";
|
import AccessSelector from "/@/views/certd/access/access-selector/index.vue";
|
||||||
import CnameVerifyPlan from "./cname-verify-plan.vue";
|
import CnameVerifyPlan from "./cname-verify-plan.vue";
|
||||||
import HttpVerifyPlan from "./http-verify-plan.vue";
|
import HttpVerifyPlan from "./http-verify-plan.vue";
|
||||||
|
//@ts-ignore
|
||||||
import psl from "psl";
|
import psl from "psl";
|
||||||
import { Form } from "ant-design-vue";
|
import { Form } from "ant-design-vue";
|
||||||
import { DomainsVerifyPlanInput } from "./type";
|
import { DomainsVerifyPlanInput } from "./type";
|
||||||
import { CnameRecord } from "./api";
|
import { CnameRecord, DomainGroupItem } from "./api";
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "DomainsVerifyPlanEditor"
|
name: "DomainsVerifyPlanEditor"
|
||||||
});
|
});
|
||||||
|
@ -136,7 +137,7 @@ function showError(error: string) {
|
||||||
errorMessageRef.value = error;
|
errorMessageRef.value = error;
|
||||||
}
|
}
|
||||||
|
|
||||||
type DomainGroup = Record<string, Record<string, CnameRecord>>;
|
type DomainGroup = Record<string, DomainGroupItem>;
|
||||||
|
|
||||||
function onDomainsChanged(domains: string[]) {
|
function onDomainsChanged(domains: string[]) {
|
||||||
if (domains == null) {
|
if (domains == null) {
|
||||||
|
@ -145,8 +146,8 @@ function onDomainsChanged(domains: string[]) {
|
||||||
|
|
||||||
const domainGroups: DomainGroup = {};
|
const domainGroups: DomainGroup = {};
|
||||||
for (let domain of domains) {
|
for (let domain of domains) {
|
||||||
domain = domain.replace("*.", "");
|
const keyDomain = domain.replace("*.", "");
|
||||||
const parsed = psl.parse(domain);
|
const parsed = psl.parse(keyDomain);
|
||||||
if (parsed.error) {
|
if (parsed.error) {
|
||||||
showError(`域名${domain}解析失败: ${JSON.stringify(parsed.error)}`);
|
showError(`域名${domain}解析失败: ${JSON.stringify(parsed.error)}`);
|
||||||
continue;
|
continue;
|
||||||
|
@ -157,15 +158,20 @@ function onDomainsChanged(domains: string[]) {
|
||||||
}
|
}
|
||||||
let group = domainGroups[mainDomain];
|
let group = domainGroups[mainDomain];
|
||||||
if (!group) {
|
if (!group) {
|
||||||
group = {};
|
group = {
|
||||||
|
domain: mainDomain,
|
||||||
|
domains: [],
|
||||||
|
keySubDomains: []
|
||||||
|
} as DomainGroupItem;
|
||||||
domainGroups[mainDomain] = group;
|
domainGroups[mainDomain] = group;
|
||||||
}
|
}
|
||||||
group[domain] = {};
|
group.domains.push(domain);
|
||||||
|
group.keySubDomains.push(keyDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const domain in domainGroups) {
|
for (const domain in domainGroups) {
|
||||||
let planItem = planRef.value[domain];
|
let planItem = planRef.value[domain];
|
||||||
const subDomains = domainGroups[domain];
|
const domainGroupItem = domainGroups[domain];
|
||||||
if (!planItem) {
|
if (!planItem) {
|
||||||
planItem = {
|
planItem = {
|
||||||
domain,
|
domain,
|
||||||
|
@ -178,12 +184,15 @@ function onDomainsChanged(domains: string[]) {
|
||||||
};
|
};
|
||||||
planRef.value[domain] = planItem;
|
planRef.value[domain] = planItem;
|
||||||
}
|
}
|
||||||
|
planItem.domains = domainGroupItem.domains;
|
||||||
|
|
||||||
const cnameOrigin = planItem.cnameVerifyPlan;
|
const cnameOrigin = planItem.cnameVerifyPlan;
|
||||||
const httpOrigin = planItem.httpVerifyPlan;
|
const httpOrigin = planItem.httpVerifyPlan;
|
||||||
planItem.cnameVerifyPlan = {};
|
planItem.cnameVerifyPlan = {};
|
||||||
planItem.httpVerifyPlan = {};
|
planItem.httpVerifyPlan = {};
|
||||||
for (const subDomain in subDomains) {
|
const cnamePlan = planItem.cnameVerifyPlan;
|
||||||
|
const httpPlan = planItem.httpVerifyPlan;
|
||||||
|
for (const subDomain of domainGroupItem.keySubDomains) {
|
||||||
if (!cnameOrigin[subDomain]) {
|
if (!cnameOrigin[subDomain]) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
planItem.cnameVerifyPlan[subDomain] = {
|
planItem.cnameVerifyPlan[subDomain] = {
|
||||||
|
@ -192,8 +201,14 @@ function onDomainsChanged(domains: string[]) {
|
||||||
} else {
|
} else {
|
||||||
planItem.cnameVerifyPlan[subDomain] = cnameOrigin[subDomain];
|
planItem.cnameVerifyPlan[subDomain] = cnameOrigin[subDomain];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
for (const subDomain in subDomains) {
|
if (!cnamePlan[subDomain]) {
|
||||||
|
//@ts-ignore
|
||||||
|
cnamePlan[subDomain] = {
|
||||||
|
id: 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (!httpOrigin[subDomain]) {
|
if (!httpOrigin[subDomain]) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
planItem.httpVerifyPlan[subDomain] = {
|
planItem.httpVerifyPlan[subDomain] = {
|
||||||
|
@ -202,27 +217,7 @@ function onDomainsChanged(domains: string[]) {
|
||||||
} else {
|
} else {
|
||||||
planItem.httpVerifyPlan[subDomain] = httpOrigin[subDomain];
|
planItem.httpVerifyPlan[subDomain] = httpOrigin[subDomain];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const cnamePlan = planItem.cnameVerifyPlan;
|
|
||||||
for (const subDomain in subDomains) {
|
|
||||||
if (!cnamePlan[subDomain]) {
|
|
||||||
//@ts-ignore
|
|
||||||
cnamePlan[subDomain] = {
|
|
||||||
id: 0
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (const subDomain of Object.keys(cnamePlan)) {
|
|
||||||
if (!subDomains[subDomain]) {
|
|
||||||
delete cnamePlan[subDomain];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// httpVerifyPlan
|
|
||||||
const httpPlan = planItem.httpVerifyPlan;
|
|
||||||
for (const subDomain in subDomains) {
|
|
||||||
debugger;
|
|
||||||
if (!httpPlan[subDomain]) {
|
if (!httpPlan[subDomain]) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
httpPlan[subDomain] = {
|
httpPlan[subDomain] = {
|
||||||
|
@ -230,8 +225,15 @@ function onDomainsChanged(domains: string[]) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const subDomain of Object.keys(cnamePlan)) {
|
||||||
|
if (!domainGroupItem.keySubDomains.includes(subDomain)) {
|
||||||
|
delete cnamePlan[subDomain];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (const subDomain of Object.keys(httpPlan)) {
|
for (const subDomain of Object.keys(httpPlan)) {
|
||||||
if (!subDomains[subDomain]) {
|
if (!domainGroupItem.keySubDomains.includes(subDomain)) {
|
||||||
delete httpPlan[subDomain];
|
delete httpPlan[subDomain];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,7 +244,6 @@ function onDomainsChanged(domains: string[]) {
|
||||||
delete planRef.value[domain];
|
delete planRef.value[domain];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debugger;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
@ -324,12 +325,15 @@ watch(
|
||||||
padding: 10px 6px;
|
padding: 10px 6px;
|
||||||
}
|
}
|
||||||
td {
|
td {
|
||||||
border-bottom: 1px solid #e8e8e8;
|
border-bottom: 2px solid #d8d8d8;
|
||||||
border-left: 1px solid #e8e8e8;
|
border-left: 1px solid #e8e8e8;
|
||||||
padding: 6px 6px;
|
padding: 6px 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.plan {
|
.plan {
|
||||||
|
td {
|
||||||
|
border-right: 1px solid #e8e8e8 !important;
|
||||||
|
}
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
.ant-select {
|
.ant-select {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
|
@ -9,6 +9,7 @@ export type HttpRecord = {
|
||||||
|
|
||||||
export type DomainVerifyPlanInput = {
|
export type DomainVerifyPlanInput = {
|
||||||
domain: string;
|
domain: string;
|
||||||
|
domains: string[];
|
||||||
type: "cname" | "dns" | "http";
|
type: "cname" | "dns" | "http";
|
||||||
dnsProviderType?: string;
|
dnsProviderType?: string;
|
||||||
dnsProviderAccessId?: number;
|
dnsProviderAccessId?: number;
|
||||||
|
|
|
@ -18,21 +18,31 @@ function checkDomainVerifyPlan(rule: any, value: DomainsVerifyPlanInput) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (type === "http") {
|
} else if (type === "http") {
|
||||||
|
const domains = value[domain].domains || [];
|
||||||
|
for (const item of domains) {
|
||||||
|
//如果有通配符域名则不允许使用http校验
|
||||||
|
if (item.startsWith("*.")) {
|
||||||
|
throw new Error(`域名${item}为通配符域名,不支持HTTP校验`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const subDomains = Object.keys(value[domain].httpVerifyPlan);
|
const subDomains = Object.keys(value[domain].httpVerifyPlan);
|
||||||
if (subDomains.length > 0) {
|
if (subDomains.length > 0) {
|
||||||
for (const subDomain of subDomains) {
|
for (const subDomain of subDomains) {
|
||||||
const plan = value[domain].httpVerifyPlan[subDomain];
|
const plan = value[domain].httpVerifyPlan[subDomain];
|
||||||
if (plan.httpUploaderType == null) {
|
if (!plan.httpUploaderType) {
|
||||||
throw new Error(`域名${subDomain}的上传方式必须填写`);
|
throw new Error(`域名${subDomain}的上传方式必须填写`);
|
||||||
} else if (plan.httpUploaderAccess == null) {
|
}
|
||||||
|
if (!plan.httpUploaderAccess) {
|
||||||
throw new Error(`域名${subDomain}的上传授权信息必须填写`);
|
throw new Error(`域名${subDomain}的上传授权信息必须填写`);
|
||||||
} else if (plan.httpUploadRootDir == null) {
|
}
|
||||||
|
if (!plan.httpUploadRootDir) {
|
||||||
throw new Error(`域名${subDomain}的网站根路径必须填写`);
|
throw new Error(`域名${subDomain}的网站根路径必须填写`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (type === "dns") {
|
} else if (type === "dns") {
|
||||||
if (value[domain].dnsProviderType == null || value[domain].dnsProviderAccessId == null) {
|
if (!value[domain].dnsProviderType || !value[domain].dnsProviderAccessId) {
|
||||||
throw new Error(`DNS模式下,域名${domain}的DNS类型和授权信息必须填写`);
|
throw new Error(`DNS模式下,域名${domain}的DNS类型和授权信息必须填写`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,6 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
valueResolve({ form, value }) {
|
valueResolve({ form, value }) {
|
||||||
debugger;
|
|
||||||
if (value && value.productId) {
|
if (value && value.productId) {
|
||||||
form.productId = value.productId;
|
form.productId = value.productId;
|
||||||
form.duration = value.duration;
|
form.duration = value.duration;
|
||||||
|
|
|
@ -4,14 +4,13 @@ import assert from 'assert';
|
||||||
import { getApp } from '../setup.js';
|
import { getApp } from '../setup.js';
|
||||||
|
|
||||||
describe('test/controller/home.test.ts', () => {
|
describe('test/controller/home.test.ts', () => {
|
||||||
|
|
||||||
it('should POST /api/get_user', async function (this: any) {
|
it('should POST /api/get_user', async function (this: any) {
|
||||||
const app: Application = getApp();
|
const app: Application = getApp();
|
||||||
// make request
|
// make request
|
||||||
const result = await createHttpRequest(app).get('/api/get_user').query({ uid: 123 });
|
const result = await createHttpRequest(app).get('/api/get_user').query({ uid: 123 });
|
||||||
|
|
||||||
// use expect by jest
|
// use expect by jest
|
||||||
assert(result.status ===200);
|
assert(result.status === 200);
|
||||||
assert(result.body.message === 'OK');
|
assert(result.body.message === 'OK');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue