Compare commits

...

21 Commits

Author SHA1 Message Date
xiaojunnuo
2ca20be197 perf: 支持部署到阿里云云原生API网关、AI网关 2025-08-28 00:36:28 +08:00
xiaojunnuo
17f23f3751 perf: 商业版支持自定义插件的参数配置 2025-08-27 18:23:24 +08:00
xiaojunnuo
8e3d699856 chore: 2025-08-27 09:56:36 +08:00
xiaojunnuo
f1a168fa53 chore: plugin config 2025-08-26 18:42:54 +08:00
xiaojunnuo
3575113655 perf: 支持删除宝塔证书夹中的过期证书 2025-08-25 23:58:03 +08:00
xiaojunnuo
9feb9d04b3 perf: 支持部署到华为云obs 2025-08-25 23:22:17 +08:00
xiaojunnuo
5419b1439a Merge branch 'v2' into v2-dev 2025-08-25 21:52:50 +08:00
xiaojunnuo
e4489343fe perf: lecdnv2支持api token 2025-08-25 18:38:35 +08:00
xiaojunnuo
d9f4a5793d perf: 支持p7b证书格式 2025-08-25 18:21:38 +08:00
xiaojunnuo
70fcdc9ebb perf: 腾讯云EO插件支持自动获取zoneid和域名列表 2025-08-25 17:22:55 +08:00
SHAREWEBS
78e7a81638 fix: 更新我爱云CDN域名地址,和部分目录结构 @tyjsjxh (#514)
更新我爱云CDN域名地址,和部分目录结构
2025-08-25 16:30:23 +08:00
xiaojunnuo
58e82d5dbd perf: 腾讯云插件支持国际版 2025-08-25 16:19:37 +08:00
xiaojunnuo
06d15be43a chore: 2025-08-21 15:57:39 +08:00
xiaojunnuo
e1e7011853 perf: ssh 配置sudo免密提示 2025-08-19 17:06:14 +08:00
xiaojunnuo
eff7645035 chore: 移除ksyun-sdk-node包 2025-08-19 11:01:01 +08:00
xiaojunnuo
eb75e52278 fix: 修复cron选择组件星期显示错误的bug 2025-08-18 18:48:42 +08:00
xiaojunnuo
15e6148272 chore: 2025-08-18 00:28:55 +08:00
xiaojunnuo
ccd448a675 chore: 2025-08-18 00:27:31 +08:00
xiaojunnuo
db54c019ad chore: 2025-08-18 00:16:28 +08:00
xiaojunnuo
b762b4d72c build: publish 2025-08-17 23:58:37 +08:00
xiaojunnuo
2f8faa839d build: trigger build image 2025-08-17 23:58:22 +08:00
81 changed files with 1357 additions and 325 deletions

View File

@@ -1,11 +1,11 @@
---
name: Plugin Apply
about: 请求支持新部署插件
about: 部署插件申请支持
title: "[Plugin] "
labels: feature
---
> > 感谢您支持certd请按如下规范提交issue
> > 感谢您支持certd请按如下规范提交issue
> 如果有条件,请尽量在[github上提交](https://github.com/certd/certd/issues)
# 新部署插件申请支持

View File

@@ -1,12 +1,12 @@
---
name: DNS Provider Apply
about: 请求支持新的域名提供商
about: 域名提供商申请支持
title: "[DNS] "
labels: feature
---
> 感谢您支持certd请按如下规范提交issue
> 感谢您支持certd请按如下规范提交issue
> 如果有条件,请尽量在[github上提交](https://github.com/certd/certd/issues)
# 新域名提供商支持申请
@@ -14,23 +14,23 @@ labels: feature
## 1. 基本信息
请填写如下内容:
1. 域名提供商名称:
1. 域名提供商名称:
2. 管理页面地址:
3. 是否有API接口接口地址
3. 是否有API接口接口地址
4. 如果没有API接口网页登录是否有验证码
4. 如果没有API接口网页登录是否有验证码
5. 是否可以提供测试账号?(如果可以请留下联系方式或者加作者好友)
## 2. 截图
## 2. 截图
`域名管理页面截图`

View File

@@ -1,12 +1,12 @@
---
name: Bug Report
about: 报告一个错误或问题
about: 错误或问题报告
title: "[BUG] "
labels: bug
---
> 感谢您支持certd请按如下规范提交issue
> 感谢您支持certd请按如下规范提交issue
> 如果有条件,请尽量在[github上提交](https://github.com/certd/certd/issues)
# bug提交

View File

@@ -1,15 +1,16 @@
---
name: Feature Request
about: 新需求、新特性
about: 新需求、新特性申请支持
title: "[Feature] "
labels: feature
---
> > 感谢您支持certd请按如下规范提交issue
> > 感谢您支持certd请按如下规范提交issue
> 如果有条件,请尽量在[github上提交](https://github.com/certd/certd/issues)
# 新需求申请
# 新特性申请
>注意:这里仅供如果是要申请新的部署插件,请提交插件申请
## 1. 需求描述,需求背景
`请在此处简要描述你所遇到的问题,必要时请贴出相关截图辅助理解`

View File

@@ -1,37 +0,0 @@
name: sync-to-gitee-dev
on:
push:
branches: ['v2-dev']
paths:
- "build.trigger"
# schedule:
# - # 国际时间 19:17 执行北京时间3:17 ↙↙↙ 改成你想要每天自动执行的时间
# - cron: '17 19 * * *'
permissions:
contents: read
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout work repo # 1. 检出当前仓库(certd-sync-work)
uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
- name: Set git user # 2. 给git命令设置用户名和邮箱,↙↙↙ 改成你的name和email
run: |
git config --global user.name "xiaojunnuo"
git config --global user.email "xiaojunnuo@qq.com"
- name: Set git token # 3. 给git命令设置token用于push到目标仓库
uses: de-vri-es/setup-git-credentials@v2
with: # token 格式为: username:password
credentials: https://${{secrets.PUSH_TOKEN_GITEE}}@gitee.com
- name: push to gitee # 4. 执行同步
run: |
sleep 10
git remote add upstream https://gitee.com/certd/certd
git push --set-upstream upstream v2-dev

View File

@@ -1 +1 @@
12:51
23:58

View File

@@ -45,7 +45,7 @@ services:
# 设置环境变量即可自定义certd配置
# 配置项见: packages/ui/certd-server/src/config/config.default.ts
# 配置规则: certd_ + 配置项, 点号用_代替
# #↓↓↓↓ ----------------------------- 如果忘记管理员密码可以设置为true重启之后管理员密码将改成123456然后请及时修改回false
# #↓↓↓↓ ----------------------------- 如果忘记管理员密码可以设置为truedocker compose up -d 重建容器之后管理员密码将改成123456然后请及时修改回false
- certd_system_resetAdminPasswd=false
# 默认使用sqlite文件数据库如果需要使用其他数据库请设置以下环境变量

View File

@@ -3,6 +3,19 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.36.17](https://github.com/certd/certd/compare/v1.36.16...v1.36.17) (2025-08-17)
### Bug Fixes
* 修复新部署的无法保存公共eab配置的bug ([d5dee75](https://github.com/certd/certd/commit/d5dee75df3bd635a597436e448b2de1407531f3a))
### Performance Improvements
* 阿里云 FC3.0 不在要求证书加密方式为旧版, 修复支持的协议类型可以正常选择 ([a34db74](https://github.com/certd/certd/commit/a34db7449eff6ad1dda01de673bf85579fa3865a))
* 部署到腾讯云cdn每个域名增加3每秒延迟 ([f7d43ad](https://github.com/certd/certd/commit/f7d43ad5af4663d4be369820a80d1fd9817ca4ab))
* 腾讯云关闭证书通知增加开关选项,在腾讯云授权里面 ([a77c777](https://github.com/certd/certd/commit/a77c777980dd38d97d983124eeed1596879bba95))
* 证书申请任务默认不发送申请成功通知 ([0283bd2](https://github.com/certd/certd/commit/0283bd2f978dbcd13d361129135e439dd9fbc180))
## [1.36.16](https://github.com/certd/certd/compare/v1.36.15...v1.36.16) (2025-08-16)
### Bug Fixes

View File

@@ -31,7 +31,7 @@
"init": "lerna run build",
"init:dev": "lerna run build",
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:build": "npm run copylogs && vitepress build docs",
"docs:preview": "vitepress preview docs",
"pub": "echo 1"
},

View File

@@ -69,5 +69,5 @@
"bugs": {
"url": "https://github.com/publishlab/node-acme-client/issues"
},
"gitHead": "e979e9c9fb5d4e29aa4946e9c5206c222ceb0f75"
"gitHead": "831c325c6383ba0a6f2dfa7496451ec714784e93"
}

View File

@@ -45,5 +45,5 @@
"tslib": "^2.8.1",
"typescript": "^5.4.2"
},
"gitHead": "e979e9c9fb5d4e29aa4946e9c5206c222ceb0f75"
"gitHead": "831c325c6383ba0a6f2dfa7496451ec714784e93"
}

View File

@@ -44,5 +44,5 @@
"tslib": "^2.8.1",
"typescript": "^5.4.2"
},
"gitHead": "e979e9c9fb5d4e29aa4946e9c5206c222ceb0f75"
"gitHead": "831c325c6383ba0a6f2dfa7496451ec714784e93"
}

View File

@@ -24,5 +24,5 @@
"prettier": "^2.8.8",
"tslib": "^2.8.1"
},
"gitHead": "e979e9c9fb5d4e29aa4946e9c5206c222ceb0f75"
"gitHead": "831c325c6383ba0a6f2dfa7496451ec714784e93"
}

View File

@@ -31,5 +31,5 @@
"tslib": "^2.8.1",
"typescript": "^5.4.2"
},
"gitHead": "e979e9c9fb5d4e29aa4946e9c5206c222ceb0f75"
"gitHead": "831c325c6383ba0a6f2dfa7496451ec714784e93"
}

View File

@@ -61,5 +61,5 @@
"fetch"
]
},
"gitHead": "e979e9c9fb5d4e29aa4946e9c5206c222ceb0f75"
"gitHead": "831c325c6383ba0a6f2dfa7496451ec714784e93"
}

View File

@@ -32,5 +32,5 @@
"tslib": "^2.8.1",
"typescript": "^5.4.2"
},
"gitHead": "e979e9c9fb5d4e29aa4946e9c5206c222ceb0f75"
"gitHead": "831c325c6383ba0a6f2dfa7496451ec714784e93"
}

View File

@@ -61,5 +61,5 @@
"typeorm": "^0.3.11",
"typescript": "^5.4.2"
},
"gitHead": "e979e9c9fb5d4e29aa4946e9c5206c222ceb0f75"
"gitHead": "831c325c6383ba0a6f2dfa7496451ec714784e93"
}

View File

@@ -46,5 +46,5 @@
"typeorm": "^0.3.11",
"typescript": "^5.4.2"
},
"gitHead": "e979e9c9fb5d4e29aa4946e9c5206c222ceb0f75"
"gitHead": "831c325c6383ba0a6f2dfa7496451ec714784e93"
}

View File

@@ -43,5 +43,5 @@
"tslib": "^2.8.1",
"typescript": "^5.4.2"
},
"gitHead": "e979e9c9fb5d4e29aa4946e9c5206c222ceb0f75"
"gitHead": "831c325c6383ba0a6f2dfa7496451ec714784e93"
}

View File

@@ -48,6 +48,7 @@ export type CertInfo = {
der?: string;
jks?: string;
one?: string;
p7b?: string;
};
export type SSLProvider = "letsencrypt" | "google" | "zerossl";
export type PrivateKeyType = "rsa_1024" | "rsa_2048" | "rsa_3072" | "rsa_4096" | "ec_256" | "ec_384" | "ec_521";

View File

@@ -125,6 +125,10 @@ export abstract class CertApplyBaseConvertPlugin extends AbstractTaskPlugin {
cert.jks = res.jks;
}
if (cert.p7b == null && res.p7b) {
cert.p7b = res.p7b;
}
this.logger.info("转换证书格式成功");
} catch (e) {
this.logger.error("转换证书格式失败", e);
@@ -150,6 +154,7 @@ export abstract class CertApplyBaseConvertPlugin extends AbstractTaskPlugin {
zip.file("intermediate.crt", cert.ic);
zip.file("origin.crt", cert.oc);
zip.file("one.pem", cert.one);
zip.file("cert.p7b", cert.p7b);
if (cert.pfx) {
zip.file("cert.pfx", Buffer.from(cert.pfx, "base64"));
}

View File

@@ -17,6 +17,7 @@ export type CertReaderHandleContext = {
tmpIcPath?: string;
tmpJksPath?: string;
tmpOnePath?: string;
tmpP7bPath?: string;
};
export type CertReaderHandle = (ctx: CertReaderHandleContext) => Promise<void>;
export type HandleOpts = { logger: ILogger; handle: CertReaderHandle };
@@ -124,7 +125,7 @@ export class CertReader {
return domain;
}
saveToFile(type: "crt" | "key" | "pfx" | "der" | "oc" | "one" | "ic" | "jks", filepath?: string) {
saveToFile(type: "crt" | "key" | "pfx" | "der" | "oc" | "one" | "ic" | "jks" | "p7b", filepath?: string) {
if (!this.cert[type]) {
return;
}
@@ -138,7 +139,7 @@ export class CertReader {
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true });
}
if (type === "crt" || type === "key" || type === "ic" || type === "oc" || type === "one") {
if (type === "crt" || type === "key" || type === "ic" || type === "oc" || type === "one" || type === "p7b") {
fs.writeFileSync(filepath, this.cert[type]);
} else {
fs.writeFileSync(filepath, Buffer.from(this.cert[type], "base64"));
@@ -157,17 +158,19 @@ export class CertReader {
const tmpDerPath = this.saveToFile("der");
const tmpJksPath = this.saveToFile("jks");
const tmpOnePath = this.saveToFile("one");
const tmpP7bPath = this.saveToFile("p7b");
logger.info("本地文件写入成功");
try {
return await opts.handle({
reader: this,
tmpCrtPath: tmpCrtPath,
tmpKeyPath: tmpKeyPath,
tmpPfxPath: tmpPfxPath,
tmpDerPath: tmpDerPath,
tmpIcPath: tmpIcPath,
tmpJksPath: tmpJksPath,
tmpOcPath: tmpOcPath,
tmpCrtPath,
tmpKeyPath,
tmpPfxPath,
tmpDerPath,
tmpIcPath,
tmpJksPath,
tmpOcPath,
tmpP7bPath,
tmpOnePath,
});
} catch (err) {
@@ -189,6 +192,7 @@ export class CertReader {
removeFile(tmpIcPath);
removeFile(tmpJksPath);
removeFile(tmpOnePath);
removeFile(tmpP7bPath);
}
}

View File

@@ -18,11 +18,13 @@ export class CertConverter {
pfx: string;
der: string;
jks: string;
p7b: string;
}> {
const certReader = new CertReader(opts.cert);
let pfx: string;
let der: string;
let jks: string;
let p7b: string;
const handle = async (ctx: CertReaderHandleContext) => {
// 调用openssl 转pfx
pfx = await this.convertPfx(ctx, opts.pfxPassword, opts.pfxArgs);
@@ -31,6 +33,8 @@ export class CertConverter {
der = await this.convertDer(ctx);
jks = await this.convertJks(ctx, opts.pfxPassword);
p7b = await this.convertP7b(ctx);
};
await certReader.readCertFile({ logger: this.logger, handle });
@@ -39,6 +43,7 @@ export class CertConverter {
pfx,
der,
jks,
p7b,
};
}
@@ -95,6 +100,23 @@ export class CertConverter {
return derCert;
}
async convertP7b(opts: CertReaderHandleContext) {
const { tmpCrtPath } = opts;
const p7bPath = path.join(os.tmpdir(), "/certd/tmp/", Math.floor(Math.random() * 1000000) + `_cert.p7b`);
const dir = path.dirname(p7bPath);
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true });
}
//openssl crl2pkcs7 -nocrl \
// -certfile your_domain.crt \
// -certfile intermediate.crt \
// -out chain.p7b
await this.exec(`openssl crl2pkcs7 -nocrl -certfile ${tmpCrtPath} -out ${p7bPath}`);
const fileBuffer = fs.readFileSync(p7bPath);
const p7bCert = fileBuffer.toString();
fs.unlinkSync(p7bPath);
return p7bCert;
}
async convertJks(opts: CertReaderHandleContext, pfxPassword = "") {
const jksPassword = pfxPassword || "123456";
try {
@@ -113,9 +135,7 @@ export class CertConverter {
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true });
}
await this.exec(
`keytool -importkeystore -srckeystore ${p12Path} -srcstoretype PKCS12 -srcstorepass "${jksPassword}" -destkeystore ${jksPath} -deststoretype PKCS12 -deststorepass "${jksPassword}" `
);
await this.exec(`keytool -importkeystore -srckeystore ${p12Path} -srcstoretype PKCS12 -srcstorepass "${jksPassword}" -destkeystore ${jksPath} -deststoretype PKCS12 -deststorepass "${jksPassword}" `);
fs.unlinkSync(p12Path);
const fileBuffer = fs.readFileSync(jksPath);

View File

@@ -53,5 +53,5 @@
"tslib": "^2.8.1",
"typescript": "^5.4.2"
},
"gitHead": "e979e9c9fb5d4e29aa4946e9c5206c222ceb0f75"
"gitHead": "831c325c6383ba0a6f2dfa7496451ec714784e93"
}

View File

@@ -7,9 +7,9 @@ export type AliyunClientV2Req = {
// 接口 HTTP 方法
method?: "GET" | "POST";
authType?: "AK";
style?: "RPC";
style?: "RPC" | "ROA";
// 接口 PATH
pathname?: `/`;
pathname?: string;
data?: any;
};
@@ -63,10 +63,10 @@ export class AliyunClientV2 {
protocol: "HTTPS",
// 接口 HTTP 方法
method: req.method ?? "POST",
authType: "AK",
style: "RPC",
authType: req.authType ?? "AK",
style: req.style ?? "RPC",
// 接口 PATH
pathname: `/`,
pathname: req.pathname ?? `/`,
// 接口请求体内容格式
reqBodyType: "json",
// 接口响应体内容格式

View File

@@ -9,7 +9,8 @@ export type AliyunCertInfo = {
export type AliyunSslClientOpts = {
access: AliyunAccess;
logger: ILogger;
endpoint: string;
endpoint?: string;
region?: string;
};
export type AliyunSslGetResourceListReq = {
@@ -48,10 +49,19 @@ export class AliyunSslClient {
async getClient() {
const access = this.opts.access;
const client = new AliyunClient({ logger: this.opts.logger });
let endpoint = this.opts.endpoint || "cas.aliyuncs.com";
if (this.opts.endpoint == null && this.opts.region) {
if (this.opts.region === "cn-hangzhou") {
endpoint = "cas.aliyuncs.com";
} else {
endpoint = `cas.${this.opts.region}.aliyuncs.com`;
}
}
await client.init({
accessKeyId: access.accessKeyId,
accessKeySecret: access.accessKeySecret,
endpoint: `https://${this.opts.endpoint || "cas.aliyuncs.com"}`,
endpoint: `https://${endpoint}`,
apiVersion: "2020-04-07",
});
return client;

View File

@@ -5,6 +5,7 @@ import { IsAccess, AccessInput, BaseAccess } from "@certd/pipeline";
title: "天翼云授权",
desc: "",
icon: "ant-design:aliyun-outlined",
order: 2,
})
export class CtyunAccess extends BaseAccess {
@AccessInput({

View File

@@ -6,6 +6,7 @@ import { AccessInput, BaseAccess, IsAccess } from "@certd/pipeline";
desc: "",
icon: "svg:icon-qiniuyun",
input: {},
order: 2,
})
export class QiniuAccess extends BaseAccess {
@AccessInput({

View File

@@ -5,6 +5,7 @@ import { AccessInput, BaseAccess, IsAccess } from "@certd/pipeline";
desc: "",
icon: "clarity:host-line",
input: {},
order: 0,
})
export class SshAccess extends BaseAccess {
@AccessInput({

View File

@@ -247,6 +247,9 @@ export class AsyncSsh2Client {
const err = this.convert(iconv, ret);
stdErr += err;
hasErrorLog = true;
if (err.includes("sudo: a password is required")) {
this.logger.warn("请配置sudo免密否则命令无法执行");
}
this.logger.error(`[${this.connConf.host}][error]: ` + err.trimEnd());
});
});

View File

@@ -4,6 +4,7 @@ import { IsAccess, AccessInput, BaseAccess } from "@certd/pipeline";
name: "tencent",
title: "腾讯云",
icon: "svg:icon-tencentcloud",
order: 0,
})
export class TencentAccess extends BaseAccess {
@AccessInput({
@@ -59,4 +60,8 @@ export class TencentAccess extends BaseAccess {
isIntl() {
return this.accountType === "intl";
}
intlDomain() {
return this.isIntl() ? "intl." : "";
}
}

View File

@@ -26,7 +26,7 @@ export class TencentSslClient {
region: this.region,
profile: {
httpProfile: {
endpoint: "ssl.tencentcloudapi.com",
endpoint: this.access.isIntl() ? "ssl.intl.tencentcloudapi.com" : "ssl.tencentcloudapi.com",
},
},
};

View File

@@ -43,7 +43,7 @@
"@tailwindcss/typography": "^0.5.16",
"@tanstack/vue-store": "^0.7.0",
"@vee-validate/zod": "^4.15.0",
"@vue-js-cron/light": "^4.0.5",
"@certd/vue-js-cron-light": "^4.0.14",
"@vue/shared": "^3.5.13",
"@vueuse/core": "^10.11.0",
"ant-design-vue": "^4.2.6",

View File

@@ -4,8 +4,8 @@ import vip from "./vip-button/install.js";
import { CheckCircleOutlined, InfoCircleOutlined, UndoOutlined } from "@ant-design/icons-vue";
import CronEditor from "./cron-editor/index.vue";
import FoldBox from "./fold-box.vue";
import { CronLight } from "@vue-js-cron/light";
import "@vue-js-cron/light/dist/light.css";
import { CronLight } from "@certd/vue-js-cron-light";
import "@certd/vue-js-cron-light/dist/light.css";
import Plugins from "./plugins/index";
import LoadingButton from "./loading-button.vue";
import IconSelect from "./icon-select.vue";

View File

@@ -564,7 +564,7 @@ export default {
ipv6Priority: "IPv6 Priority",
dualStackNetworkHelper: "If IPv6 priority is selected, enable IPv6 in docker-compose.yaml",
enableCommonCnameService: "Enable Public CNAME Service",
commonCnameHelper: "Allow use of public CNAME service. If disabled and no <router-link to='/sys/cname/provider'>custom CNAME service</router-link> is set, CNAME proxy certificate application will not work.",
commonCnameHelper: "Allow use of public CNAME service. If disabled and no <a href='#/sys/cname/provider'>custom CNAME service</a> is set, CNAME proxy certificate application will not work.",
enableCommonSelfServicePasswordRetrieval: "Enable self-service password recovery",
saveButton: "Save",
stopSuccess: "Stopped successfully",

View File

@@ -570,7 +570,7 @@ export default {
ipv6Priority: "IPV6优先",
dualStackNetworkHelper: "如果选择IPv6优先需要在docker-compose.yaml中启用ipv6",
enableCommonCnameService: "启用公共CNAME服务",
commonCnameHelper: "是否可以使用公共CNAME服务如果禁用且没有设置<router-link to='/sys/cname/provider'>自定义CNAME服务</router-link>则无法使用CNAME代理方式申请证书",
commonCnameHelper: "是否可以使用公共CNAME服务如果禁用且没有设置<a href='#/sys/cname/provider'>自定义CNAME服务</a>则无法使用CNAME代理方式申请证书",
enableCommonSelfServicePasswordRetrieval: "启用自助找回密码",
saveButton: "保存",
stopSuccess: "停止成功",

View File

@@ -133,7 +133,7 @@ export const sysResources = [
title: "certd.sysResources.sysPluginConfig",
name: "SysPluginConfig",
path: "/sys/plugin/config",
component: "/sys/plugin/config.vue",
component: "/sys/plugin/config-common.vue",
meta: {
show: () => {
const settingStore = useSettingStore();

View File

@@ -1,7 +1,8 @@
import { defineStore } from "pinia";
import * as api from "./api.plugin";
import { DynamicType, FormItemProps } from "@fast-crud/fast-crud";
import { DynamicType, FormItemProps, useMerge } from "@fast-crud/fast-crud";
import { i18n } from "/src/locales/i18n";
import { cloneDeep } from "lodash-es";
interface PluginState {
group?: PluginGroups;
}
@@ -32,14 +33,17 @@ export class PluginGroups {
groups!: { [key: string]: PluginGroup };
map!: { [key: string]: PluginDefine };
t: any;
constructor(groups: { [key: string]: PluginGroup }) {
mergeSetting?: boolean;
constructor(groups: { [key: string]: PluginGroup }, opts?: { mergeSetting?: boolean }) {
this.groups = groups;
this.t = i18n.global.t;
this.mergeSetting = opts?.mergeSetting ?? false;
this.initGroup(groups);
this.initMap();
}
private initGroup(groups: { [p: string]: PluginGroup }) {
const { merge } = useMerge();
const all: PluginGroup = {
key: "all",
title: this.t("certd.all"),
@@ -48,6 +52,14 @@ export class PluginGroups {
icon: "material-symbols:border-all-rounded",
};
for (const key in groups) {
if (this.mergeSetting) {
for (const plugin of groups[key].plugins) {
if (plugin.sysSetting) {
merge(plugin.input, plugin.sysSetting.metadata);
}
}
}
all.plugins.push(...groups[key].plugins);
}
this.groups = {
@@ -132,11 +144,15 @@ export const usePluginStore = defineStore({
id: "app.plugin",
state: (): PluginState => ({
group: null,
originGroup: null,
}),
actions: {
async reload() {
const groups = await api.GetGroups({});
this.group = new PluginGroups(groups);
this.group = new PluginGroups(groups, { mergeSetting: true });
this.originGroup = new PluginGroups(cloneDeep(groups));
console.log("group", this.group);
console.log("originGroup", this.originGroup);
},
async init() {
if (!this.group) {
@@ -159,6 +175,10 @@ export const usePluginStore = defineStore({
await this.init();
return this.group.get(name);
},
async getPluginDefineFromOrigin(name: string): Promise<PluginDefine> {
await this.init();
return this.originGroup.get(name);
},
async getPluginConfig(query: any) {
return await api.GetPluginConfig(query);
},

View File

@@ -304,3 +304,11 @@ h6 {
padding: 10px;
color: #6e6e6e;
}
.ant-modal-body{
.fs-form-body{
max-height: 66vh;
overflow-y: auto;
}
}

View File

@@ -84,6 +84,7 @@ export function getCommonColumnDefine(crudExpose: any, typeRef: any, api: any) {
component: {
color: "auto",
},
order: -1,
},
form: {
component: {

View File

@@ -82,6 +82,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
},
column: {
width: 300,
order: -11,
},
},
from: {

View File

@@ -138,6 +138,7 @@ export function useCertPipelineCreator() {
form: {
doSubmit,
wrapper: {
wrapClassName: "cert_pipeline_create_form",
width: 1350,
saveRemind: false,
title: t("certd.pipelineForm.createTitle"),

View File

@@ -115,4 +115,13 @@ function batchRerun() {
padding-left: 10px;
}
}
.cert_pipeline_create_form {
.ant-collapse {
margin: 10px;
}
.ant-collapse-header {
text-align: right;
}
}
</style>

View File

@@ -43,7 +43,7 @@
</a-tab-pane>
</a-tabs>
<a-form-item>
<a-button type="primary" size="large" html-type="submit" :loading="loading" class="login-button">
<a-button type="primary" size="large" html-type="button" :loading="loading" class="login-button" @click="handleFinish">
{{ t("authentication.loginButton") }}
</a-button>
@@ -217,7 +217,6 @@ export default defineComponent({
</script>
<style lang="less">
.login-page.main {
//margin: 20px !important;
margin-bottom: 100px;

View File

@@ -97,6 +97,7 @@ export type CertApplyPluginSysInput = {
export type PluginSysSetting<T> = {
sysSetting: {
input?: T;
metadata?: Record<string, any>;
};
};
export type CommPluginConfig = {
@@ -118,6 +119,14 @@ export async function SaveCommPluginConfigs(data: CommPluginConfig): Promise<voi
});
}
export async function savePluginSetting(req: { id: number; metadata: any }): Promise<void> {
return await request({
url: apiPrefix + "/saveSetting",
method: "post",
data: req,
});
}
export async function DoTest(req: { id: number; input: any }): Promise<void> {
return await request({
url: apiPrefix + "/doTest",

View File

@@ -0,0 +1,177 @@
<template>
<div class="plugin-config">
<div class="origin-metadata w-100%">
<div class="block-title">
自定义插件参数配置
<div class="helper">1111</div>
</div>
<div class="p-10">
<div ref="formRef" class="config-form w-full" :label-col="labelCol" :wrapper-col="wrapperCol">
<table class="table-fixed w-full">
<thead>
<tr>
<th class="text-left p-5" width="200px">插件参数</th>
<th class="text-left p-5" width="100px">参数配置</th>
<th class="text-left flex-1 p-5">自定义</th>
</tr>
</thead>
<tbody>
<template v-for="(item, key) in originInputs" :key="key">
<template v-for="prop in editableKeys" :key="prop.key">
<tr>
<td v-if="prop.key === 'value'" class="border-t-2 p-5" rowspan="3" :class="{ 'border-t-2': prop.key === 'value' }">{{ item.title }}</td>
<td class="border-t p-5" :class="{ 'border-t-2': prop.key === 'value' }">{{ prop.label }}</td>
<td class="border-t p-5" :class="{ 'border-t-2': prop.key === 'value' }">
<rollbackable :value="configForm[key][prop.key]" @set="configForm[key][prop.key] = item[prop.key] ?? null" @clear="delete configForm[key][prop.key]">
<template #default>
<fs-render :render-func="prop.defaultRender(key, item)"></fs-render>
</template>
<template #edit>
<fs-render :render-func="prop.editRender(key, item)"></fs-render>
</template>
</rollbackable>
</td>
</tr>
</template>
</template>
</tbody>
</table>
</div>
</div>
</div>
</div>
</template>
<script setup lang="tsx">
import { computed, nextTick, onMounted, reactive, ref, Ref, unref } from "vue";
import { useRoute, useRouter } from "vue-router";
import * as api from "./api";
import { usePluginStore } from "/@/store/plugin";
import { cloneDeep, get, merge, set, unset } from "lodash-es";
import Rollbackable from "./rollbackable.vue";
import { FsRender } from "@fast-crud/fast-crud";
const route = useRoute();
const router = useRouter();
const pluginStore = usePluginStore();
const props = defineProps<{
plugin: any;
}>();
const pluginMetadata = ref<any>("");
const currentPlugin = ref();
const labelCol = ref({
span: null,
style: {
width: "145px",
},
});
const wrapperCol = ref({ span: 16 });
const configForm: any = reactive({});
function getScope() {
return {
form: configForm,
};
}
function getScopeFunc() {
return getScope;
}
function getForm() {
return configForm;
}
const editableKeys = ref([
{
key: "value",
label: "默认值",
defaultRender(key: string, item: any) {
return () => {
return item["value"] ?? "";
};
},
editRender(key: string, item: any) {
return () => {
return <fs-component-render {...item.component} vModel:modelValue={configForm[key]["value"]} scope={getScope()} />;
};
},
},
{
key: "show",
label: "是否显示",
defaultRender(key: string, item: any) {
return () => {
const value = item["show"];
return value === false ? "不显示" : "显示";
};
},
editRender(key: string, item: any) {
return () => {
return <a-switch vModel:checked={configForm[key]["show"]} />;
};
},
},
{
key: "helper",
label: "帮助说明",
defaultRender(key: string, item: any) {
return () => {
return <pre class={"helper"}>{item["helper"]}</pre>;
};
},
editRender(key: string, item: any) {
return () => {
return <a-textarea rows={5} vModel:value={configForm[key]["helper"]} />;
};
},
},
]);
const originInputs = computed(() => {
if (!currentPlugin.value) {
return;
}
const input = cloneDeep(currentPlugin.value.input);
const newInputs: any = {};
for (const key in input) {
const value = input[key];
value.key = key;
const newInput: any = cloneDeep(value);
newInputs[key] = newInput;
}
return newInputs;
});
function clearFormValue(key: string) {
unset(configForm, key);
console.log(key, configForm);
}
async function loadPluginSetting() {
currentPlugin.value = await pluginStore.getPluginDefineFromOrigin(props.plugin.name);
for (const key in currentPlugin.value.input) {
configForm[key] = {};
}
const setting = props.plugin.sysSetting;
if (setting) {
const settingJson = JSON.parse(setting);
merge(configForm, settingJson.metadata);
}
}
onMounted(async () => {
await loadPluginSetting();
});
defineExpose({
getForm,
});
</script>
<style lang="less">
.plugin-config {
pre {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}
}
</style>

View File

@@ -1,11 +1,14 @@
import * as api from "./api";
import { useI18n } from "/src/locales";
import { Ref, ref } from "vue";
import { Ref, ref, computed } from "vue";
import { useRouter } from "vue-router";
import { AddReq, compute, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, useFormWrapper, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
import { Modal, notification } from "ant-design-vue";
import { AddReq, compute, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
import { Modal } from "ant-design-vue";
//@ts-ignore
import yaml from "js-yaml";
import { usePluginImport } from "./use-import";
import { usePluginConfig } from "./use-config";
import { useSettingStore } from "/src/store/settings/index";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const router = useRouter();
@@ -35,75 +38,11 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
const selectedRowKeys: Ref<any[]> = ref([]);
context.selectedRowKeys = selectedRowKeys;
const { openCrudFormDialog } = useFormWrapper();
async function openImportDialog() {
function createCrudOptions() {
return {
crudOptions: {
columns: {
content: {
title: t("certd.pluginFile"),
type: "text",
form: {
component: {
name: "pem-input",
vModel: "modelValue",
textarea: {
rows: 8,
},
},
col: {
span: 24,
},
helper: t("certd.selectPluginFile"),
},
},
override: {
title: t("certd.overrideSameName"),
type: "dict-switch",
dict: dict({
data: [
{
value: true,
label: t("certd.override"),
},
{
value: false,
label: t("certd.noOverride"),
},
],
}),
form: {
value: false,
col: {
span: 24,
},
helper: t("certd.overrideHelper"),
},
},
},
form: {
wrapper: {
title: t("certd.importPlugin"),
saveRemind: false,
},
afterSubmit() {
notification.success({ message: t("certd.operationSuccess") });
crudExpose.doRefresh();
},
async doSubmit({ form }: any) {
return await api.ImportPlugin({
...form,
});
},
},
},
};
}
const { crudOptions } = createCrudOptions();
await openCrudFormDialog({ crudOptions });
}
const { openImportDialog } = usePluginImport();
const { openConfigDialog } = usePluginConfig();
const settingStore = useSettingStore();
return {
crudOptions: {
settings: {
@@ -139,7 +78,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
text: t("certd.import"),
type: "primary",
async click() {
await openImportDialog();
await openImportDialog({ crudExpose });
},
},
},
@@ -186,6 +125,21 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
}
},
},
config: {
show: computed(() => {
return settingStore.isComm;
}),
text: null,
icon: "ion:settings-outline",
title: t("certd.config"),
type: "link",
async click({ row }) {
await openConfigDialog({
row,
crudExpose,
});
},
},
},
},
table: {

View File

@@ -0,0 +1,45 @@
<script setup lang="ts">
import { defineProps } from "vue";
const props = defineProps<{ value: any }>();
const emits = defineEmits(["set", "clear"]);
function setValue() {
emits("set");
}
function clearValue() {
emits("clear");
}
</script>
<template>
<div class="rollbackable">
<div class="flex">
<div style="width: 100px">
<a-tag v-if="value === undefined" color="green" size="small" class="pointer flex-inline items-center" @click.stop="setValue">
<fs-icon icon="material-symbols:edit" class="mr-5"></fs-icon>
自定义
</a-tag>
<a-tag v-else color="red" size="small" class="pointer flex-inline items-center" @click.stop="clearValue">
<fs-icon icon="material-symbols:undo" class="mr-5"></fs-icon>
还原
</a-tag>
</div>
<div class="flex-1 overflow-hidden value-render">
<slot v-if="value === undefined" name="default"></slot>
<slot v-else name="edit"></slot>
</div>
</div>
</div>
</template>
<style lang="less">
.rollbackable {
.value-render {
.ant-select,
.ant-input {
width: 100%;
}
}
}
</style>

View File

@@ -0,0 +1,73 @@
import * as api from "/@/views/sys/plugin/api";
import { useFormWrapper } from "@fast-crud/fast-crud";
import { useI18n } from "/@/locales";
import { Modal, notification } from "ant-design-vue";
import ConfigEditor from "./config-editor.vue";
import { useModal } from "/@/use/use-modal";
import { ref } from "vue";
export function usePluginConfig() {
const { openCrudFormDialog } = useFormWrapper();
const { t } = useI18n();
const modal = useModal();
async function openConfigDialog({ row, crudExpose }) {
const configEditorRef = ref();
function createCrudOptions() {
return {
crudOptions: {
columns: {},
form: {
wrapper: {
width: "80%",
title: "插件元数据配置",
saveRemind: false,
slots: {
"form-body-top": () => {
return (
<div>
<ConfigEditor ref={configEditorRef} plugin={row}></ConfigEditor>
</div>
);
},
},
},
afterSubmit() {
notification.success({ message: t("certd.operationSuccess") });
crudExpose.doRefresh();
},
async doSubmit({}: any) {
const form = configEditorRef.value.getForm();
const newForm: any = {};
for (const key in form) {
const value = form[key];
if (value && Object.keys(value).length > 0) {
newForm[key] = value;
}
}
return await api.savePluginSetting({
name: row.name,
sysSetting: {
metadata: newForm,
},
});
},
},
},
};
}
const { crudOptions } = createCrudOptions();
await openCrudFormDialog({ crudOptions });
// modal.confirm({
// title: "插件元数据配置",
// width: "80%",
// content: () => {
// return <ConfigEditor plugin={row}></ConfigEditor>;
// },
// });
}
return {
openConfigDialog,
};
}

View File

@@ -0,0 +1,80 @@
import * as api from "/@/views/sys/plugin/api";
import { useFormWrapper } from "@fast-crud/fast-crud";
import { useI18n } from "/@/locales";
import { Modal, notification } from "ant-design-vue";
export function usePluginImport() {
const { openCrudFormDialog } = useFormWrapper();
const { t } = useI18n();
async function openImportDialog({ crudExpose }) {
function createCrudOptions() {
return {
crudOptions: {
columns: {
content: {
title: t("certd.pluginFile"),
type: "text",
form: {
component: {
name: "pem-input",
vModel: "modelValue",
textarea: {
rows: 8,
},
},
col: {
span: 24,
},
helper: t("certd.selectPluginFile"),
},
},
override: {
title: t("certd.overrideSameName"),
type: "dict-switch",
dict: dict({
data: [
{
value: true,
label: t("certd.override"),
},
{
value: false,
label: t("certd.noOverride"),
},
],
}),
form: {
value: false,
col: {
span: 24,
},
helper: t("certd.overrideHelper"),
},
},
},
form: {
wrapper: {
title: t("certd.importPlugin"),
saveRemind: false,
},
afterSubmit() {
notification.success({ message: t("certd.operationSuccess") });
crudExpose.doRefresh();
},
async doSubmit({ form }: any) {
return await api.ImportPlugin({
...form,
});
},
},
},
};
}
const { crudOptions } = createCrudOptions();
await openCrudFormDialog({ crudOptions });
}
return {
openImportDialog,
};
}

View File

@@ -8,7 +8,7 @@
<a-form-item v-if="formState.yizhifu.enabled" label="易支付配置" :name="['yizhifu', 'accessId']" :required="true">
<access-selector v-model="formState.yizhifu.accessId" type="yizhifu" from="sys" />
<div class="helper">
<a href="https://certd.docmirror.cn/comm/payments/yizhifu.html">彩虹易支付配置帮助文档</a>
<a href="https://certd.docmirror.cn/guide/use/comm/payments/yizhifu.html">彩虹易支付配置帮助文档</a>
</div>
</a-form-item>
@@ -17,7 +17,7 @@
</a-form-item>
<a-form-item v-if="formState.alipay.enabled" label="支付宝配置" :name="['alipay', 'accessId']" :required="true">
<access-selector v-model="formState.alipay.accessId" type="alipay" from="sys" />
<div class="helper">需要开通电脑网站支付 <a href="https://certd.docmirror.cn/comm/payments/alipay.html">支付宝配置帮助文档</a></div>
<div class="helper">需要开通电脑网站支付 <a href="https://certd.docmirror.cn/guide/use/comm/payments/alipay.html">支付宝配置帮助文档</a></div>
</a-form-item>
<a-form-item label="微信支付" :name="['wxpay', 'enabled']" :required="true">
@@ -25,7 +25,7 @@
</a-form-item>
<a-form-item v-if="formState.wxpay.enabled" label="微信支付配置" :name="['wxpay', 'accessId']" :required="true">
<access-selector v-model="formState.wxpay.accessId" type="wxpay" from="sys" />
<div class="helper">需要开通Native支付 <a href="https://certd.docmirror.cn/comm/payments/wxpay.html">微信配置帮助文档</a></div>
<div class="helper">需要开通Native支付 <a href="https://certd.docmirror.cn/guide/use/comm/payments/wxpay.html">微信配置帮助文档</a></div>
</a-form-item>
<a-form-item label=" " :colon="false" :wrapper-col="{ span: 16 }">

View File

@@ -9,7 +9,6 @@
```
```shell
npm run heap
```

View File

@@ -82,6 +82,7 @@
"cross-env": "^7.0.3",
"crypto-js": "^4.2.0",
"dayjs": "^1.11.7",
"esdk-obs-nodejs": "^3.25.6",
"form-data": "^4.0.0",
"glob": "^11.0.0",
"https-proxy-agent": "^7.0.5",
@@ -91,7 +92,6 @@
"jsonwebtoken": "^9.0.0",
"jszip": "^3.10.1",
"koa-send": "^5.0.1",
"ksyun-sdk-node": "^1.2.4",
"kubernetes-client": "^9.0.0",
"lodash-es": "^4.17.21",
"log4js": "^6.7.1",

View File

@@ -2,7 +2,11 @@ import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/c
import { merge } from 'lodash-es';
import { CrudController } from '@certd/lib-server';
import { PluginImportReq, PluginService } from "../../../modules/plugin/service/plugin-service.js";
import { CommPluginConfig, PluginConfigService } from '../../../modules/plugin/service/plugin-config-service.js';
import {
CommPluginConfig,
PluginConfig,
PluginConfigService
} from '../../../modules/plugin/service/plugin-config-service.js';
/**
* 插件
*/
@@ -79,7 +83,11 @@ export class PluginController extends CrudController<PluginService> {
const res = await this.pluginConfigService.saveCommPluginConfig(body);
return this.ok(res);
}
@Post('/saveSetting', { summary: 'sys:settings:edit' })
async saveSetting(@Body(ALL) body: PluginConfig) {
const res = await this.pluginConfigService.savePluginConfig(body);
return this.ok(res);
}
@Post('/import', { summary: 'sys:settings:edit' })
async import(@Body(ALL) body: PluginImportReq) {

View File

@@ -3,9 +3,10 @@ import { PluginService } from './plugin-service.js';
export type PluginConfig = {
name: string;
disabled: boolean;
disabled?: boolean;
sysSetting: {
input?: Record<string, any>;
metadata?: Record<string, any>;
};
};
@@ -37,10 +38,12 @@ export class PluginConfigService {
}
async saveCommPluginConfig(config: CommPluginConfig) {
await this.savePluginConfig('CertApply', config.CertApply);
config.CertApply.name = 'CertApply';
await this.savePluginConfig(config.CertApply);
}
async savePluginConfig(name: string, config: PluginConfig) {
async savePluginConfig( config: PluginConfig) {
const name = config.name;
const sysSetting = config?.sysSetting;
if (!sysSetting) {
throw new Error(`${name}.sysSetting is required`);
@@ -57,7 +60,14 @@ export class PluginConfigService {
author: "certd",
});
} else {
await this.pluginService.getRepository().update({ name }, { sysSetting: JSON.stringify(sysSetting) });
let setting = JSON.parse(pluginEntity.sysSetting || "{}");
if (sysSetting.metadata) {
setting.metadata = sysSetting.metadata;
}
if (sysSetting.input) {
setting.input = sysSetting.input;
}
await this.pluginService.getRepository().update({ name }, { sysSetting: JSON.stringify(setting) });
}
}

View File

@@ -1,16 +1,16 @@
import { Inject, Provide, Scope, ScopeEnum } from "@midwayjs/core";
import { BaseService, PageReq } from "@certd/lib-server";
import { PluginEntity } from "../entity/plugin.js";
import { InjectEntityModel } from "@midwayjs/typeorm";
import { Repository } from "typeorm";
import { isComm } from "@certd/plus-core";
import { BuiltInPluginService } from "../../pipeline/service/builtin-plugin-service.js";
import { merge } from "lodash-es";
import { accessRegistry, notificationRegistry, pluginRegistry } from "@certd/pipeline";
import { dnsProviderRegistry } from "@certd/plugin-cert";
import { logger } from "@certd/basic";
import {Inject, Provide, Scope, ScopeEnum} from "@midwayjs/core";
import {BaseService, PageReq} from "@certd/lib-server";
import {PluginEntity} from "../entity/plugin.js";
import {InjectEntityModel} from "@midwayjs/typeorm";
import {IsNull, Not, Repository} from "typeorm";
import {isComm} from "@certd/plus-core";
import {BuiltInPluginService} from "../../pipeline/service/builtin-plugin-service.js";
import {merge} from "lodash-es";
import {accessRegistry, notificationRegistry, pluginRegistry} from "@certd/pipeline";
import {dnsProviderRegistry} from "@certd/plugin-cert";
import {logger} from "@certd/basic";
import yaml from "js-yaml";
import { getDefaultAccessPlugin, getDefaultDeployPlugin, getDefaultDnsPlugin } from "./default-plugin.js";
import {getDefaultAccessPlugin, getDefaultDeployPlugin, getDefaultDnsPlugin} from "./default-plugin.js";
import fs from "fs";
import path from "path";
@@ -57,9 +57,9 @@ export class PluginService extends BaseService<PluginEntity> {
};
}
async getEnabledBuildInGroup(isSimple = false) {
async getEnabledBuildInGroup(opts?:{isSimple?:boolean,withSetting?:boolean}) {
const groups = this.builtInPluginService.getGroups();
if (isSimple) {
if (opts?.isSimple) {
for (const key in groups) {
const group = groups[key];
group.plugins.forEach(item => {
@@ -72,9 +72,43 @@ export class PluginService extends BaseService<PluginEntity> {
if (!isComm()) {
return groups;
}
// 初始化设置
const settingPlugins = await this.repository.find({
select:{
id:true,
name:true,
sysSetting:true
},
where: {
sysSetting : Not(IsNull())
}
})
//合并插件配置
const pluginSettingMap:any = {}
for (const item of settingPlugins) {
if (!item.sysSetting) {
continue;
}
pluginSettingMap[item.name] = JSON.parse(item.sysSetting);
}
for (const key in groups) {
const group = groups[key];
if (!group.plugins) {
continue;
}
for (const item of group.plugins) {
const pluginSetting = pluginSettingMap[item.name];
if (pluginSetting){
item.sysSetting = pluginSetting
}
}
}
//排除禁用的
const list = await this.list({
query: {
type: "builtIn",
disabled: true
}
});

View File

@@ -0,0 +1,272 @@
import {AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput} from '@certd/pipeline';
import {
AliyunAccess,
AliyunSslClient,
createCertDomainGetterInputDefine,
createRemoteSelectInputDefine
} from "@certd/plugin-lib";
import { CertApplyPluginNames, CertInfo, CertReader } from "@certd/plugin-cert";
import {optionsUtils} from "@certd/basic/dist/utils/util.options.js";
@IsTaskPlugin({
name: 'DeployCertToAliyunApig',
title: '阿里云-部署至云原生API网关/AI网关',
icon: 'svg:icon-aliyun',
group: pluginGroups.aliyun.key,
desc: '自动部署域名证书至云原生API网关、AI网关',
default: {
strategy: {
runStrategy: RunStrategy.SkipWhenSucceed,
},
},
})
export class DeployCertToAliyunApig extends AbstractTaskPlugin {
@TaskInput({
title: '域名证书',
helper: '请选择前置任务输出的域名证书',
component: {
name: 'output-selector',
from: [...CertApplyPluginNames, 'uploadCertToAliyun'],
},
required: true,
})
cert!: CertInfo | string;
@TaskInput(createCertDomainGetterInputDefine({ props: { required: false } }))
certDomains!: string[];
@TaskInput({
title: 'Access授权',
helper: '阿里云授权',
component: {
name: 'access-selector',
type: 'aliyun',
},
required: true,
})
accessId!: string;
@TaskInput(
createRemoteSelectInputDefine({
title: '区域',
helper: '请选择区域',
action: DeployCertToAliyunApig.prototype.onGetRegionList.name,
watches: ['certDomains', 'accessId'],
required: true,
component:{
name:"remote-auto-complete"
}
})
)
regionEndpoint!: string;
@TaskInput({
title: "网关类型",
component: {
name: "a-select",
vModel:"value",
options:[
{value:"AI",label:"AI"},
{value:"API",label:"API"},
]
},
required: true //必填
})
gatewayType!: string;
@TaskInput(
createRemoteSelectInputDefine({
title: '绑定域名',
helper: '请选择域名',
action: DeployCertToAliyunApig.prototype.onGetDomainList.name,
watches: ['region', 'accessId','gatewayType'],
required: true,
})
)
domainList!: string[];
@TaskInput({
title: "强制HTTPS",
component: {
name: "a-select",
vModel:"value",
options:[
{value:true,label:"强制HTTPS"},
{value:false,label:"不强制HTTPS"},
]
},
required: true //必填
})
forceHttps!: boolean;
@TaskInput({
title: '证书服务接入点',
helper: '不会选就按默认',
value: 'cn-hangzhou',
component: {
name: 'a-select',
options: [
{ value: 'cn-hangzhou', label: '中国大陆' },
{ value: 'ap-southeast-1', label: '新加坡' },
],
},
required: true,
})
casRegion!: string;
async onInstance() {}
async execute(): Promise<void> {
this.logger.info('开始部署证书到云原生Api网关');
if(!this.domainList){
throw new Error('您还未选择域名');
}
const access = await this.getAccess<AliyunAccess>(this.accessId);
const client = access.getClient(this.regionEndpoint)
let certId: any = this.cert;
if (typeof this.cert === 'object') {
const sslClient = new AliyunSslClient({
access,
logger: this.logger,
region: this.casRegion,
});
certId = await sslClient.uploadCert({
name: this.buildCertName(CertReader.getMainDomain(this.cert.crt)),
cert: this.cert,
});
}
const certIdentify = `${certId}-${this.casRegion}`
for (const domainId of this.domainList ) {
this.logger.info(`[${domainId}]开始部署`)
await this.updateCert(client, domainId,certIdentify);
this.logger.info(`[${domainId}]部署成功`)
}
this.logger.info('部署完成');
}
async updateCert(client: any, domainId: string,certIdentify:string) {
const domainInfoRes = await client.doRequest({
action: "GetDomain",
version: "2024-03-27",
protocol: "HTTPS",
method: "GET",
authType: "AK",
style: "ROA",
pathname: `/v1/domains/${domainId}`,
});
const tlsCipherSuitesConfig = domainInfoRes.data?.tlsCipherSuitesConfig
const ret = await client.doRequest({
action: "UpdateDomain",
version: "2024-03-27",
method: "PUT",
style: "ROA",
pathname: `/v1/domains/${domainId}`,
data:{
body:{
certIdentifier: certIdentify,
protocol: "HTTPS",
forceHttps:this.forceHttps,
tlsCipherSuitesConfig
}
}
})
this.logger.info(`设置${domainId}证书成功:`, ret.requestId);
}
async onGetDomainList(data: any) {
if (!this.accessId) {
throw new Error('请选择Access授权');
}
if (!this.regionEndpoint) {
throw new Error('请选择区域');
}
if (!this.gatewayType) {
throw new Error('请选择网关类型');
}
const access = await this.getAccess<AliyunAccess>(this.accessId);
const client = access.getClient(this.regionEndpoint)
const res =await client.doRequest({
action: "ListDomains",
version: "2024-03-27",
method: "GET",
style: "ROA",
pathname: `/v1/domains`,
data:{
query:{
pageSize: 100,
gatewayType: this.gatewayType ,
}
}
})
const list = res?.data?.items;
if (!list || list.length === 0) {
return []
}
const options = list.map((item: any) => {
return {
value: item.domainId,
label: `${item.name}<${item.domainId}>`,
domain: item.name,
};
});
return optionsUtils.buildGroupOptions(options, this.certDomains);
}
async onGetRegionList(data: any) {
const list = [
{value:"cn-qingdao",label:"华北1青岛",endpoint:"apig.cn-qingdao.aliyuncs.com"},
{value:"cn-beijing",label:"华北2北京",endpoint:"apig.cn-beijing.aliyuncs.com"},
{value:"cn-zhangjiakou",label:"华北3张家口",endpoint:"apig.cn-zhangjiakou.aliyuncs.com"},
{value:"cn-wulanchabu",label:"华北6乌兰察布",endpoint:"apig.cn-wulanchabu.aliyuncs.com"},
{value:"cn-hangzhou",label:"华东1杭州",endpoint:"apig.cn-hangzhou.aliyuncs.com"},
{value:"cn-shanghai",label:"华东2上海",endpoint:"apig.cn-shanghai.aliyuncs.com"},
{value:"cn-shenzhen",label:"华南1深圳",endpoint:"apig.cn-shenzhen.aliyuncs.com"},
{value:"cn-heyuan",label:"华南2河源",endpoint:"apig.cn-heyuan.aliyuncs.com"},
{value:"cn-guangzhou",label:"华南3广州",endpoint:"apig.cn-guangzhou.aliyuncs.com"},
{value:"ap-southeast-2",label:"澳大利亚(悉尼)已关停",endpoint:"apig.ap-southeast-2.aliyuncs.com"},
{value:"ap-southeast-6",label:"菲律宾(马尼拉)",endpoint:"apig.ap-southeast-6.aliyuncs.com"},
{value:"ap-northeast-2",label:"韩国(首尔)",endpoint:"apig.ap-northeast-2.aliyuncs.com"},
{value:"ap-southeast-3",label:"马来西亚(吉隆坡)",endpoint:"apig.ap-southeast-3.aliyuncs.com"},
{value:"ap-northeast-1",label:"日本(东京)",endpoint:"apig.ap-northeast-1.aliyuncs.com"},
{value:"ap-southeast-7",label:"泰国(曼谷)",endpoint:"apig.ap-southeast-7.aliyuncs.com"},
{value:"cn-chengdu",label:"西南1成都",endpoint:"apig.cn-chengdu.aliyuncs.com"},
{value:"ap-southeast-1",label:"新加坡",endpoint:"apig.ap-southeast-1.aliyuncs.com"},
{value:"ap-southeast-5",label:"印度尼西亚(雅加达)",endpoint:"apig.ap-southeast-5.aliyuncs.com"},
{value:"cn-hongkong",label:"中国香港",endpoint:"apig.cn-hongkong.aliyuncs.com"},
{value:"eu-central-1",label:"德国(法兰克福)",endpoint:"apig.eu-central-1.aliyuncs.com"},
{value:"us-east-1",label:"美国(弗吉尼亚)",endpoint:"apig.us-east-1.aliyuncs.com"},
{value:"us-west-1",label:"美国(硅谷)",endpoint:"apig.us-west-1.aliyuncs.com"},
{value:"eu-west-1",label:"英国(伦敦)",endpoint:"apig.eu-west-1.aliyuncs.com"},
{value:"me-east-1",label:"阿联酋(迪拜)",endpoint:"apig.me-east-1.aliyuncs.com"},
{value:"me-central-1",label:"沙特(利雅得)",endpoint:"apig.me-central-1.aliyuncs.com"},
]
return list.map((item: any) => {
return {
value: item.endpoint,
label: item.label,
endpoint: item.endpoint,
regionId : item.value
};
})
}
}
new DeployCertToAliyunApig();

View File

@@ -10,3 +10,4 @@ export * from './deploy-to-fc/index.js';
export * from './deploy-to-esa/index.js';
export * from './deploy-to-vod/index.js';
export * from './deploy-to-apigateway/index.js';
export * from './deploy-to-apig/index.js';

View File

@@ -14,8 +14,9 @@ import { CertApplyPluginNames, CertReader } from "@certd/plugin-cert";
*/
const regionDict = [
{ value: 'cn-hangzhou', endpoint: 'cas.aliyuncs.com', label: 'cn-hangzhou-中国大陆' },
{ value: 'eu-central-1', endpoint: 'cas.eu-central-1.aliyuncs.com', label: 'eu-central-1-德国(法兰克福)' },
{ value: 'ap-southeast-1', endpoint: 'cas.ap-southeast-1.aliyuncs.com', label: 'ap-southeast-1-新加坡(国际版选这个)' },
{ value: 'private-', endpoint: '', disabled:true, label: '以下是私有证书区域' },
{ value: 'eu-central-1', endpoint: 'cas.eu-central-1.aliyuncs.com', label: 'eu-central-1-德国(法兰克福)' },
{ value: 'ap-southeast-3', endpoint: 'cas.ap-southeast-3.aliyuncs.com', label: 'ap-southeast-3-马来西亚(吉隆坡)' },
{ value: 'ap-southeast-5', endpoint: 'cas.ap-southeast-5.aliyuncs.com', label: 'ap-southeast-5-印度尼西亚(雅加达)' },
{ value: 'cn-hongkong', endpoint: 'cas.cn-hongkong.aliyuncs.com', label: 'cn-hongkong-中国香港' },

View File

@@ -16,6 +16,7 @@ type DemoRecord = {
icon: 'clarity:plugin-line',
// 这里是对应的云平台的access类型名称
accessType: 'demo',
order:99,
})
export class DemoDnsProvider extends AbstractDnsProvider<DemoRecord> {
access!: DemoAccess;

View File

@@ -39,6 +39,7 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
{ value: 'der', label: 'der一般用于Apache' },
{ value: 'jks', label: 'jks一般用于JAVA应用' },
{ value: 'one', label: '证书私钥一体crt+key简单合并为一个pem文件' },
{ value: 'p7b', label: 'p7b格式' },
],
},
required: true,
@@ -71,7 +72,7 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
mergeScript: `
return {
show: ctx.compute(({form})=>{
return form.certType === 'pem';
return form.certType === 'pem' || form.certType === 'p7b' ;
})
}
`,
@@ -169,6 +170,24 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
})
onePath!: string;
@TaskInput({
title: 'p7b证书保存路径',
helper: '填写应用原本的证书保存路径,路径要包含证书文件名,例如:/tmp/domain_cert.p7b',
component: {
placeholder: '/root/deploy/app/domain_cert.p7b',
},
mergeScript: `
return {
show: ctx.compute(({form})=>{
return form.certType === 'p7b';
})
}
`,
required: true,
rules: [{ type: 'filepath' }],
})
p7bPath!: string;
@TaskInput({
title: '主机登录配置',
helper: 'access授权',
@@ -277,12 +296,17 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
})
hostOnePath!: string;
@TaskOutput({
title: 'p7b证书保存路径',
})
hostP7bPath!: string;
async onInstance() {}
async execute(): Promise<void> {
const { cert, accessId } = this;
let { crtPath, keyPath, icPath, pfxPath, derPath, jksPath, onePath } = this;
let { crtPath, keyPath, icPath, pfxPath, derPath, jksPath, onePath,p7bPath } = this;
const certReader = new CertReader(cert);
const executeCmd = async ( script:string)=> {
@@ -308,6 +332,7 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
env['HOST_DER_PATH'] = this.hostDerPath || '';
env['HOST_JKS_PATH'] = this.hostJksPath || '';
env['HOST_ONE_PATH'] = this.hostOnePath || '';
env['HOST_P7B_PATH'] = this.hostOnePath || '';
}
const scripts = script.split('\n');
@@ -320,7 +345,7 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
}
const handle = async (opts: CertReaderHandleContext) => {
const { tmpCrtPath, tmpKeyPath, tmpDerPath, tmpJksPath, tmpPfxPath, tmpIcPath, tmpOnePath } = opts;
const { tmpCrtPath, tmpKeyPath, tmpDerPath, tmpJksPath, tmpPfxPath, tmpIcPath, tmpOnePath ,tmpP7bPath} = opts;
if (accessId == null) {
this.logger.error('复制到当前主机功能已迁移到 “复制到本机”插件,请换成复制到本机插件');
@@ -392,6 +417,14 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
remotePath: this.onePath,
});
}
if (this.p7bPath) {
this.logger.info(`上传p7b证书到主机${this.p7bPath}`);
p7bPath = this.p7bPath.trim();
transports.push({
localPath: tmpP7bPath,
remotePath: this.p7bPath,
});
}
this.logger.info('开始上传文件到服务器');
await sshClient.uploadFiles({
@@ -410,6 +443,7 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
this.hostDerPath = derPath;
this.hostJksPath = jksPath;
this.hostOnePath = onePath;
this.hostP7bPath = p7bPath;
};
//执行前置命令

View File

@@ -5,6 +5,7 @@ import { IsAccess, AccessInput, BaseAccess } from '@certd/pipeline';
title: '华为云授权',
desc: '',
icon: 'svg:icon-huawei',
order: 0,
})
export class HuaweiAccess extends BaseAccess {
@AccessInput({

View File

@@ -0,0 +1,185 @@
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
import { HuaweiAccess } from "../../access/index.js";
import { CertApplyPluginNames, CertInfo } from "@certd/plugin-cert";
import { createCertDomainGetterInputDefine, createRemoteSelectInputDefine } from "@certd/plugin-lib";
@IsTaskPlugin({
name: 'HauweiDeployCertToOBS',
title: '华为云-部署证书至OBS',
icon: 'svg:icon-huawei',
group: pluginGroups.huawei.key,
desc: '',
default: {
strategy: {
runStrategy: RunStrategy.SkipWhenSucceed,
},
},
})
export class HauweiDeployCertToOBS extends AbstractTaskPlugin {
@TaskInput({
title: '域名证书',
helper: '请选择前置任务输出的域名证书\n如果你选择使用ccm证书ID则需要在[域名管理页面右上角开启SCM授权](https://console.huaweicloud.com/cdn/#/cdn/domain)',
component: {
name: 'output-selector',
from: [...CertApplyPluginNames,'HauweiUploadToCCM'],
},
required: true,
})
cert!: CertInfo | string;
@TaskInput(createCertDomainGetterInputDefine({ props: { required: false } }))
certDomains!: string[];
@TaskInput({
title: 'Access授权',
helper: '华为云授权AccessKeyId、AccessKeySecret',
component: {
name: 'access-selector',
type: 'huawei',
},
required: true,
})
accessId!: string;
@TaskInput(
createRemoteSelectInputDefine({
title: '存储桶',
helper: '请选择存储桶',
action: HauweiDeployCertToOBS.prototype.onGetBucketList.name,
})
)
bucketList!: string[];
@TaskInput(
createRemoteSelectInputDefine({
title: '自定义域名',
helper: '请选择自定义域名',
action: HauweiDeployCertToOBS.prototype.onGetDomainList.name,
watches: ['bucketList'],
})
)
domainList!: string[];
async execute(): Promise<void> {
if (!this.cert) {
throw new Error('域名证书不能为空');
}
this.logger.info('开始部署证书到华为云obs');
for (const domainStr of this.domainList) {
const [location, bucket,domain] = domainStr.split('_');
await this.setDomainCert({
location,
bucket,
domain,
cert: this.cert
});
}
this.logger.info('部署证书到华为云cdn完成');
}
checkRet(ret: any){
if (ret?.CommonMsg?.Status>300){
throw new Error(`${ret?.CommonMsg?.Code}${ret?.CommonMsg?.Message}`);
}
}
async getObsClient(opts:{region?:string,bucket?:string} = {}) {
const { region,bucket } = opts;
const regionStr = region? `${region}.`: 'cn-north-4.';
const bucketStr = bucket? `${bucket}.` : '';
const access = await this.getAccess<HuaweiAccess>(this.accessId);
const sdk = await import('esdk-obs-nodejs');
const obsClient = new sdk.default({
// 推荐通过环境变量获取AKSK这里也可以使用其他外部引入方式传入如果使用硬编码可能会存在泄露风险
// 您可以登录访问管理控制台获取访问密钥AK/SK获取方式请参见https://support.huaweicloud.com/usermanual-ca/ca_01_0003.html
access_key_id: access.accessKeyId,
secret_access_key: access.accessKeySecret,
// 【可选】如果使用临时AK/SK和SecurityToken访问OBS同样建议您尽量避免使用硬编码以降低信息泄露风险。您可以通过环境变量获取访问密钥AK/SK也可以使用其他外部引入方式传入
// security_token: process.env.SECURITY_TOKEN,
// endpoint填写Bucket对应的Endpoint, 这里以华北-北京四为例,其他地区请按实际情况填写
server: `https://${bucketStr}obs.${regionStr}myhuaweicloud.com`,
});
return obsClient
}
async onGetBucketList(data: any) {
const obsClient = await this.getObsClient();
const res = await obsClient.listBuckets({
QueryLocation:true
})
this.checkRet(res)
const list = res.InterfaceResult?.Buckets
if (!list || list.length === 0) {
return []
}
return list.map(item => {
return {
value: `${item.Location}_${item.BucketName}`,
label: `${item.BucketName}<${item.Location}>`,
};
});
}
async onGetDomainList(data:any) {
if (!this.bucketList || this.bucketList.length === 0) {
return []
}
const optionList = []
for (const item of this.bucketList) {
const [location,bucket] = item.split('_')
const obsClient = await this.getObsClient({region:location});
const res = await obsClient.getBucketCustomDomain({
Bucket: bucket,
})
this.checkRet(res)
const list = res.InterfaceResult?.Domains
if (!list || list.length === 0) {
continue
}
const options= list.map(item => {
return {
value: `${location}_${bucket}_${item.DomainName}`,
label: `${item.DomainName}<${bucket}_${location}>`,
domain: item.DomainName,
};
});
optionList.push(...options)
}
return this.ctx.utils.options.buildGroupOptions( optionList,this.certDomains)
}
async setDomainCert(opts:{location:string,bucket:string,domain:string,cert:string|CertInfo}){
const {location,bucket,domain,cert} = opts
const obsClient = await this.getObsClient({region:location});
const params:any = {
Bucket: bucket,
DomainName: domain,
Name: this.buildCertName( domain)
};
if (typeof cert === 'string'){
params.CertificateId= cert
}else{
params.Certificate= cert.crt
params.PrivateKey = cert.key
}
const res = await obsClient.setBucketCustomDomain(params)
this.checkRet(res)
}
}
new HauweiDeployCertToOBS();

View File

@@ -1,2 +1,3 @@
export * from './deploy-to-cdn/index.js'
export * from './upload-to-ccm/index.js'
export * from './deploy-to-obs/index.js'

View File

@@ -9,6 +9,7 @@ import {AccessInput, BaseAccess, IsAccess} from '@certd/pipeline';
title: '京东云',
desc: '',
icon: 'svg:icon-jdcloud',
order: 1,
})
export class JDCloudAccess extends BaseAccess {

View File

@@ -6,7 +6,8 @@ import { JDCloudAccess } from "./access.js";
title: "京东云",
desc: "京东云DNS解析提供商",
accessType: "jdcloud",
icon: "svg:icon-jdcloud"
icon: "svg:icon-jdcloud",
order:3,
})
export class JDCloudDnsProvider extends AbstractDnsProvider {
access!: JDCloudAccess;

View File

@@ -9,7 +9,8 @@ import { CertInfo } from "@certd/plugin-cert";
name: "rainyun",
title: "雨云授权",
desc: "https://app.rainyun.com/",
icon: "svg:icon-lucky"
icon: "svg:icon-lucky",
order: 100
})
export class RainyunAccess extends BaseAccess {

View File

@@ -7,7 +7,6 @@ import { RainyunAccess } from "./access.js";
desc: "雨云DNS解析提供商",
accessType: "rainyun",
icon: "svg:icon-lucky",
order: 0
})
export class RainyunDnsProvider extends AbstractDnsProvider {

View File

@@ -122,7 +122,7 @@ export class DeployCertToTencentAll extends AbstractTaskPlugin {
region: this.region,
profile: {
httpProfile: {
endpoint: 'ssl.tencentcloudapi.com',
endpoint: `ssl.${access.intlDomain()}tencentcloudapi.com`,
},
},
});

View File

@@ -104,7 +104,7 @@ export class TencentDeployCertToCDNv2 extends AbstractTaskPlugin {
region: '',
profile: {
httpProfile: {
endpoint: 'cdn.tencentcloudapi.com',
endpoint: `cdn.${accessProvider.intlDomain()}tencentcloudapi.com`,
},
},
};

View File

@@ -80,7 +80,7 @@ export class DeployToCdnPlugin extends AbstractTaskPlugin {
region: '',
profile: {
httpProfile: {
endpoint: 'cdn.tencentcloudapi.com',
endpoint: `cdn.${accessProvider.intlDomain()}tencentcloudapi.com`,
},
},
};

View File

@@ -119,7 +119,7 @@ export class DeployCertToTencentCLB extends AbstractTaskPlugin {
region: region,
profile: {
httpProfile: {
endpoint: 'clb.tencentcloudapi.com',
endpoint: `clb.${accessProvider.intlDomain()}tencentcloudapi.com`,
},
},
};

View File

@@ -1,5 +1,11 @@
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline";
import { TencentAccess } from "@certd/plugin-lib";
import {AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput} from "@certd/pipeline";
import {
createCertDomainGetterInputDefine,
createRemoteSelectInputDefine,
TencentAccess,
TencentSslClient
} from "@certd/plugin-lib";
import {CertApplyPluginNames, CertInfo, CertReader} from "@certd/plugin-cert";
@IsTaskPlugin({
name: 'DeployCertToTencentEO',
@@ -14,16 +20,21 @@ import { TencentAccess } from "@certd/plugin-lib";
},
})
export class DeployCertToTencentEO extends AbstractTaskPlugin {
@TaskInput({
title: '已上传证书ID',
helper: '请选择前置任务上传到腾讯云的证书',
title: '域名证书',
helper: '请选择前置任务输出的域名证书,或者选择前置任务“上传证书到腾讯云”任务的证书ID',
component: {
name: 'output-selector',
from: 'UploadCertToTencent',
from: [...CertApplyPluginNames, 'UploadCertToTencent'],
},
required: true,
})
certId!: string;
cert!: CertInfo | string;
@TaskInput(createCertDomainGetterInputDefine({ props: { required: false } }))
certDomains!: string[];
@TaskInput({
title: 'Access提供者',
@@ -36,31 +47,35 @@ export class DeployCertToTencentEO extends AbstractTaskPlugin {
})
accessId!: string;
@TaskInput({
@TaskInput(createRemoteSelectInputDefine({
title: '站点ID',
helper: '类似于zone-xxxx的字符串在站点概览页面左上角或者站点列表页面站点名称下方',
action: DeployCertToTencentEO.prototype.onGetZoneList.name,
watches: ['certDomains', 'accessId'],
required: true,
})
component:{
name:"remote-auto-complete"
}
}))
zoneId!: string;
@TaskInput(
createRemoteSelectInputDefine({
title: '加速域名',
helper: '请选择域名或输入域名',
action: DeployCertToTencentEO.prototype.onGetDomainList.name,
})
)
domainNames!: string[];
@TaskInput({
title: '证书名称',
helper: '证书上传后将以此参数作为名称前缀',
})
certName!: string;
@TaskInput({
title: 'cdn加速域名',
component: {
name: 'a-select',
vModel: 'value',
mode: 'tags',
open: false,
},
helper: '支持多个域名',
rules: [{ required: true, message: '该项必填' }],
})
domainNames!: string[];
// @TaskInput({
// title: "CDN接口",
@@ -80,16 +95,41 @@ export class DeployCertToTencentEO extends AbstractTaskPlugin {
}
async execute(): Promise<void> {
const accessProvider: TencentAccess = (await this.getAccess(this.accessId)) as TencentAccess;
const accessProvider = await this.getAccess<TencentAccess>(this.accessId)
const client = this.getClient(accessProvider);
const params = this.buildParams();
const sslClient = new TencentSslClient({
access:accessProvider,
logger: this.logger,
});
let tencentCertId = this.cert as string;
if (typeof this.cert !== 'string') {
const certReader = new CertReader(this.cert);
tencentCertId = await sslClient.uploadToTencent({
certName: certReader.buildCertName(),
cert: this.cert,
});
}
const params:any = {
ZoneId: this.zoneId,
Hosts: this.domainNames,
Mode: 'sslcert',
ServerCertInfo: [
{
CertId: tencentCertId,
},
],
};
await this.doRequest(client, params);
}
getClient(accessProvider: TencentAccess) {
const TeoClient = this.Client;
const endpoint = accessProvider.isIntl()?"teo.intl.tencentcloudapi.com": "teo.tencentcloudapi.com";
//teo.intl.tencentcloudapi.com
const endpoint = `teo.${accessProvider.intlDomain()}tencentcloudapi.com`;
const clientConfig = {
credential: {
secretId: accessProvider.secretId,
@@ -106,18 +146,6 @@ export class DeployCertToTencentEO extends AbstractTaskPlugin {
return new TeoClient(clientConfig);
}
buildParams() {
return {
ZoneId: this.zoneId,
Hosts: this.domainNames,
Mode: 'sslcert',
ServerCertInfo: [
{
CertId: this.certId,
},
],
};
}
async doRequest(client: any, params: any) {
const ret = await client.ModifyHostsCertificate(params);
@@ -131,6 +159,57 @@ export class DeployCertToTencentEO extends AbstractTaskPlugin {
throw new Error('执行失败:' + ret.Error.Code + ',' + ret.Error.Message);
}
}
async onGetZoneList(data: any) {
if (!this.accessId){
throw new Error('请选择授权');
}
const access: TencentAccess = await this.getAccess<TencentAccess>(this.accessId);
const client = await this.getClient(access);
const res = await client.DescribeZones({
Limit: 100,
});
this.checkRet(res);
const list = res.Zones;
if (!list || list.length === 0) {
return [];
}
return list.map((item: any) => {
return {
label: `${item.ZoneName}<${item.ZoneId}>`,
value: item.ZoneId,
};
});
}
async onGetDomainList(data: any) {
if (!this.accessId){
throw new Error('请选择授权');
}
const access: TencentAccess = await this.getAccess<TencentAccess>(this.accessId);
const client = await this.getClient(access);
const res = await client.DescribeAccelerationDomains({
Limit: 200,
ZoneId: this.zoneId,
});
this.checkRet(res);
const list = res.AccelerationDomains
if (!list || list.length === 0) {
return [];
}
const options = list.map((item: any) => {
return {
label: item.DomainName,
value: item.DomainName,
domain: item.DomainName
};
});
return this.ctx.utils.options.buildGroupOptions(options, this.certDomains);
}
}
new DeployCertToTencentEO();

View File

@@ -101,7 +101,7 @@ export class TencentDeployCertToLive extends AbstractTaskPlugin {
region: '',
profile: {
httpProfile: {
endpoint: 'live.tencentcloudapi.com',
endpoint: `live.${accessProvider.intlDomain()}tencentcloudapi.com`,
},
},
};

View File

@@ -210,7 +210,7 @@ export class DeployCertToTencentTKEIngressPlugin extends AbstractTaskPlugin {
region,
profile: {
httpProfile: {
endpoint: "tke.tencentcloudapi.com"
endpoint: `tke.${accessProvider.intlDomain()}tencentcloudapi.com`
}
}
};

View File

@@ -151,7 +151,7 @@ export class TencentActionInstancesPlugin extends AbstractTaskPlugin {
region: this.region,
profile: {
httpProfile: {
endpoint: 'cvm.tencentcloudapi.com',
endpoint: `cvm.${accessProvider.intlDomain()}tencentcloudapi.com`,
},
},
};

View File

@@ -9,6 +9,7 @@ import {AccessInput, BaseAccess, IsAccess} from '@certd/pipeline';
title: '火山引擎',
desc: '',
icon: 'svg:icon-volcengine',
order: 1,
})
export class VolcengineAccess extends BaseAccess {

View File

@@ -8,7 +8,8 @@ import { VolcengineAccess } from "./access.js";
title: "火山引擎",
desc: "火山引擎DNS解析提供商",
accessType: "volcengine",
icon: "svg:icon-volcengine"
icon: "svg:icon-volcengine",
order:2,
})
export class VolcengineDnsProvider extends AbstractDnsProvider {
client: VolcengineDnsClient;

View File

@@ -17,14 +17,14 @@ import { CertApplyPluginNames} from '@certd/plugin-cert';
export class WoaiCdnPlugin extends AbstractTaskPlugin {
@TaskInput({
title: '接口地址(可留空)',
helper: '请填写我爱云的地址, 默认为 [API](https://console.edeg.sxhjgy.cn) 末尾请不要携带`/`',
helper: '请填写我爱云的地址, 默认为 [API](https://console.edge.ttzi.cn) 末尾请不要携带`/`',
component: { name: 'a-input' },
required: false,
})
baseApi?: string;
@TaskInput({
title: '证书ID',
helper: '请填写 [证书列表](https://console.edge.sxhjgy.cn/site/certificate) 中的证书的ID',
helper: '请填写 [证书列表](https://console.edge.ttzi.cn/site/certificate) 中的证书的ID',
component: { name: 'a-input' },
required: true,
})
@@ -73,9 +73,9 @@ export class WoaiCdnPlugin extends AbstractTaskPlugin {
const { baseApi, certId, cert, accessId } = this;
const access = (await this.getAccess(accessId)) as WoaiAccess;
// 使用默认值或用户输入的值
const apiBase = baseApi || 'https://console.edeg.sxhjgy.cn';
const apiBase = baseApi || 'https://console.edge.ttzi.cn';
// 登录获取token
const loginResponse = await this.doRequestApi(`${apiBase}/account/login`, {
const loginResponse = await this.doRequestApi(`${apiBase}/login`, {
username: access.username,
password: access.password,
});

153
pnpm-lock.yaml generated
View File

@@ -49,7 +49,7 @@ importers:
packages/core/acme-client:
dependencies:
'@certd/basic':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../basic
'@peculiar/x509':
specifier: ^1.11.0
@@ -210,10 +210,10 @@ importers:
packages/core/pipeline:
dependencies:
'@certd/basic':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../basic
'@certd/plus-core':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../pro/plus-core
dayjs:
specifier: ^1.11.7
@@ -418,7 +418,7 @@ importers:
packages/libs/lib-k8s:
dependencies:
'@certd/basic':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../core/basic
'@kubernetes/client-node':
specifier: 0.21.0
@@ -458,16 +458,16 @@ importers:
packages/libs/lib-server:
dependencies:
'@certd/acme-client':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../core/acme-client
'@certd/basic':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../core/basic
'@certd/pipeline':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../core/pipeline
'@certd/plus-core':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../pro/plus-core
'@midwayjs/cache':
specifier: ~3.14.0
@@ -610,16 +610,16 @@ importers:
packages/plugins/plugin-cert:
dependencies:
'@certd/acme-client':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../core/acme-client
'@certd/basic':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../core/basic
'@certd/pipeline':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../core/pipeline
'@certd/plugin-lib':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../plugin-lib
'@google-cloud/publicca':
specifier: ^1.3.0
@@ -701,10 +701,10 @@ importers:
specifier: ^3.787.0
version: 3.810.0(aws-crt@1.26.2)
'@certd/basic':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../core/basic
'@certd/pipeline':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../core/pipeline
'@kubernetes/client-node':
specifier: 0.21.0
@@ -792,19 +792,19 @@ importers:
packages/pro/commercial-core:
dependencies:
'@certd/basic':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../core/basic
'@certd/lib-server':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../libs/lib-server
'@certd/pipeline':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../core/pipeline
'@certd/plugin-plus':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../plugin-plus
'@certd/plus-core':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../plus-core
'@midwayjs/core':
specifier: ~3.20.3
@@ -889,22 +889,22 @@ importers:
specifier: ^1.0.2
version: 1.0.3
'@certd/basic':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../core/basic
'@certd/lib-k8s':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../libs/lib-k8s
'@certd/pipeline':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../core/pipeline
'@certd/plugin-cert':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../plugins/plugin-cert
'@certd/plugin-lib':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../plugins/plugin-lib
'@certd/plus-core':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../plus-core
ali-oss:
specifier: ^6.21.0
@@ -1007,7 +1007,7 @@ importers:
packages/pro/plus-core:
dependencies:
'@certd/basic':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../core/basic
dayjs:
specifier: ^1.11.7
@@ -1082,6 +1082,9 @@ importers:
'@aws-sdk/s3-request-presigner':
specifier: ^3.535.0
version: 3.810.0
'@certd/vue-js-cron-light':
specifier: ^4.0.14
version: 4.0.14
'@ctrl/tinycolor':
specifier: ^4.1.0
version: 4.1.0
@@ -1121,9 +1124,6 @@ importers:
'@vee-validate/zod':
specifier: ^4.15.0
version: 4.15.0(vue@3.5.14(typescript@5.8.3))(zod@3.24.4)
'@vue-js-cron/light':
specifier: ^4.0.5
version: 4.0.10
'@vue/shared':
specifier: ^3.5.13
version: 3.5.14
@@ -1297,10 +1297,10 @@ importers:
version: 0.1.3(zod@3.24.4)
devDependencies:
'@certd/lib-iframe':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../libs/lib-iframe
'@certd/pipeline':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../core/pipeline
'@rollup/plugin-commonjs':
specifier: ^25.0.7
@@ -1483,46 +1483,46 @@ importers:
specifier: ^3.705.0
version: 3.810.0(aws-crt@1.26.2)
'@certd/acme-client':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../core/acme-client
'@certd/basic':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../core/basic
'@certd/commercial-core':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../pro/commercial-core
'@certd/cv4pve-api-javascript':
specifier: ^8.4.1
version: 8.4.1
'@certd/jdcloud':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../libs/lib-jdcloud
'@certd/lib-huawei':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../libs/lib-huawei
'@certd/lib-k8s':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../libs/lib-k8s
'@certd/lib-server':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../libs/lib-server
'@certd/midway-flyway-js':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../libs/midway-flyway-js
'@certd/pipeline':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../core/pipeline
'@certd/plugin-cert':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../plugins/plugin-cert
'@certd/plugin-lib':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../plugins/plugin-lib
'@certd/plugin-plus':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../pro/plugin-plus
'@certd/plus-core':
specifier: ^1.36.15
specifier: ^1.36.17
version: link:../../pro/plus-core
'@huaweicloud/huaweicloud-sdk-cdn':
specifier: ^3.1.120
@@ -1602,6 +1602,9 @@ importers:
dayjs:
specifier: ^1.11.7
version: 1.11.13
esdk-obs-nodejs:
specifier: ^3.25.6
version: 3.25.6
form-data:
specifier: ^4.0.0
version: 4.0.2
@@ -1629,9 +1632,6 @@ importers:
koa-send:
specifier: ^5.0.1
version: 5.0.1
ksyun-sdk-node:
specifier: ^1.2.4
version: 1.2.4(encoding@0.1.13)
kubernetes-client:
specifier: ^9.0.0
version: 9.0.0
@@ -2769,6 +2769,12 @@ packages:
'@certd/cv4pve-api-javascript@8.4.1':
resolution: {integrity: sha512-jxlRieJmCA0Z9LnwX6Ra6ZekRGJEu8o8RGYoKU0Jjkhc9jm6ChEbVyfE7Iw49/hlpA+2yaHdAXb46au/afCISg==}
'@certd/vue-js-cron-core@6.0.3':
resolution: {integrity: sha512-kqzoAMhYz9j6FGNWEODRYtt4NpUEUwjpkU89z5WVg2tCtOcI5VhwyUGOd8AxiBCRfd6PtXvzuqw85PaOps9wrQ==}
'@certd/vue-js-cron-light@4.0.14':
resolution: {integrity: sha512-Ebng/VvrN/WpzCMnt0MrsPNgPY3BP6jNYLSUlV5eES6dqWXFpCyIXbNI+qep8fWdn7rNXDW310uUsn3bCPvvEw==}
'@colors/colors@1.5.0':
resolution: {integrity: sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==}
engines: {node: '>=0.1.90'}
@@ -5162,12 +5168,6 @@ packages:
resolution: {integrity: sha512-W8R6+7UIhx06s2kpsJ0KF80IKAiIad71HUKssonMChyI37h5oFnPf6zONcX2ikXc5M8xdOiKFRxoCO8ChEob0g==}
engines: {node: '>=12'}
'@vue-js-cron/core@5.4.2':
resolution: {integrity: sha512-y5HrgLJ/0JMXUliOdJZQbB+9UHs7+b7/spe8GFt/a1iCM1ILGKxAoTfbeapoSbF9LxDgw9SsXTgdkmMKWum58A==}
'@vue-js-cron/light@4.0.10':
resolution: {integrity: sha512-ri8Or3fOkA5pSAihdTcgqrQKzCIa9QcvfilyAqEfEhkK6bTFxQVqJ9LW6tLiNaepHlU8IE68xBLM/kms67le2g==}
'@vue-macros/common@1.16.1':
resolution: {integrity: sha512-Pn/AWMTjoMYuquepLZP813BIcq8DTZiNCoaceuNlvaYuOTd8DqBZWc5u0uOMQZMInwME1mdSmmBAcTluiV9Jtg==}
engines: {node: '>=16.14.0'}
@@ -7390,6 +7390,10 @@ packages:
resolution: {integrity: sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==}
engines: {node: '>=12'}
esdk-obs-nodejs@3.25.6:
resolution: {integrity: sha512-bDEznGBoSjqmFNjkL0PvkMzF6o50wa+1PSKQ1tT5CtBP/yw7Egx0c/kIVsu5Raqcip1SjKu7muzslG4xo/skew==}
engines: {node: '>=0.12.7'}
eslint-config-prettier@8.10.0:
resolution: {integrity: sha512-SM8AMJdeQqRYT9O9zguiruQZaN7+z+E4eAP9oiLNGKMtomwaB1E9dcgUD6ZAn/eQAb52USbvezbiljfZUhbJcg==}
hasBin: true
@@ -9189,9 +9193,6 @@ packages:
kolorist@1.8.0:
resolution: {integrity: sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==}
ksyun-sdk-node@1.2.4:
resolution: {integrity: sha512-W/c1nhnZskadPP7ObmizMh+jJeHXWka0HkS8lcZfLWxwEH83B8iMFF0DrtSaDCjQRuBpgzwDLGbbp+U1D1rXlQ==}
kubernetes-client@9.0.0:
resolution: {integrity: sha512-Qy8o42dZVHB9P+cIiKdWpQbz/65l/qW1fDYvlzzeSLftmL1Ne3HEiM+0TmKAwNuRW0pTJN2tRWhcccToclxJ8g==}
engines: {node: '>=10.13.0'}
@@ -15453,6 +15454,14 @@ snapshots:
transitivePeerDependencies:
- supports-color
'@certd/vue-js-cron-core@6.0.3':
dependencies:
mustache: 4.2.0
'@certd/vue-js-cron-light@4.0.14':
dependencies:
'@certd/vue-js-cron-core': 6.0.3
'@colors/colors@1.5.0':
optional: true
@@ -18522,14 +18531,6 @@ snapshots:
- buffer
- supports-color
'@vue-js-cron/core@5.4.2':
dependencies:
mustache: 4.2.0
'@vue-js-cron/light@4.0.10':
dependencies:
'@vue-js-cron/core': 5.4.2
'@vue-macros/common@1.16.1(vue@3.5.14(typescript@5.8.3))':
dependencies:
'@vue/compiler-sfc': 3.5.14
@@ -21386,6 +21387,13 @@ snapshots:
escape-string-regexp@5.0.0: {}
esdk-obs-nodejs@3.25.6:
dependencies:
fast-xml-parser: 4.5.0
log4js: 6.9.1
transitivePeerDependencies:
- supports-color
eslint-config-prettier@8.10.0(eslint@7.32.0):
dependencies:
eslint: 7.32.0
@@ -21527,13 +21535,13 @@ snapshots:
resolve: 1.22.10
semver: 6.3.1
eslint-plugin-prettier@3.4.1(eslint-config-prettier@8.10.0(eslint@8.57.0))(eslint@7.32.0)(prettier@2.8.8):
eslint-plugin-prettier@3.4.1(eslint-config-prettier@8.10.0(eslint@7.32.0))(eslint@7.32.0)(prettier@2.8.8):
dependencies:
eslint: 7.32.0
prettier: 2.8.8
prettier-linter-helpers: 1.0.0
optionalDependencies:
eslint-config-prettier: 8.10.0(eslint@8.57.0)
eslint-config-prettier: 8.10.0(eslint@7.32.0)
eslint-plugin-prettier@4.2.1(eslint-config-prettier@8.10.0(eslint@8.57.0))(eslint@8.57.0)(prettier@2.8.8):
dependencies:
@@ -23518,17 +23526,6 @@ snapshots:
kolorist@1.8.0: {}
ksyun-sdk-node@1.2.4(encoding@0.1.13):
dependencies:
abort-controller: 3.0.0
core-js: 3.42.0
crypto-js: 4.2.0
dayjs: 1.11.13
node-fetch: 2.7.0(encoding@0.1.13)
qs: 6.14.0
transitivePeerDependencies:
- encoding
kubernetes-client@9.0.0:
dependencies:
'@kubernetes/client-node': 0.10.2
@@ -24252,7 +24249,7 @@ snapshots:
eslint: 7.32.0
eslint-config-prettier: 8.10.0(eslint@7.32.0)
eslint-plugin-node: 11.1.0(eslint@7.32.0)
eslint-plugin-prettier: 3.4.1(eslint-config-prettier@8.10.0(eslint@8.57.0))(eslint@7.32.0)(prettier@2.8.8)
eslint-plugin-prettier: 3.4.1(eslint-config-prettier@8.10.0(eslint@7.32.0))(eslint@7.32.0)(prettier@2.8.8)
execa: 5.1.1
inquirer: 7.3.3
json5: 2.2.3