mirror of
https://github.com/certd/certd.git
synced 2026-04-23 03:27:25 +08:00
add gcore
This commit is contained in:
@@ -2,7 +2,7 @@ import { AccessInput, BaseAccess, IsAccess } from '@certd/pipeline';
|
||||
|
||||
@IsAccess({
|
||||
name: 'CacheFly',
|
||||
title: 'CacheFly 授权',
|
||||
title: 'CacheFly',
|
||||
desc: 'CacheFly',
|
||||
})
|
||||
export class CacheflyAccess extends BaseAccess {
|
||||
@@ -26,9 +26,8 @@ export class CacheflyAccess extends BaseAccess {
|
||||
@AccessInput({
|
||||
title: 'totp key',
|
||||
component: {
|
||||
placeholder: 'totp key',
|
||||
placeholder: '两步验证 key',
|
||||
},
|
||||
required: true,
|
||||
encrypt: true,
|
||||
})
|
||||
otpkey = '';
|
||||
|
||||
+13
-10
@@ -60,22 +60,25 @@ export class CacheFlyPlugin extends AbstractTaskPlugin {
|
||||
async execute(): Promise<void> {
|
||||
const { cert, accessId } = this;
|
||||
const access = (await this.accessService.getById(accessId)) as CacheflyAccess;
|
||||
const otpkey = access.otpkey;
|
||||
const response = await this.http.request<any, any>({
|
||||
url: `https://cn-api.my-api.cn/api/totp/?key=${otpkey}`,
|
||||
method: 'get',
|
||||
});
|
||||
const otp = response;
|
||||
let otp = null;
|
||||
if (access.otpkey) {
|
||||
const response = await this.http.request<any, any>({
|
||||
url: `https://cn-api.my-api.cn/api/totp/?key=${access.otpkey}`,
|
||||
method: 'get',
|
||||
});
|
||||
otp = response;
|
||||
this.logger.info('获取到otp:', otp);
|
||||
}
|
||||
this.logger.info('获取到otp:', otp);
|
||||
const loginResponse = await this.doRequestApi(`${this.baseApi}/api/2.6/auth/login`, {
|
||||
username: access.username,
|
||||
password: access.password,
|
||||
otp: otp,
|
||||
...(otp && { otp }),
|
||||
});
|
||||
const token = loginResponse.token;
|
||||
this.logger.info('获取到Token:', token);
|
||||
this.logger.info('Token 获取成功');
|
||||
// 更新证书
|
||||
const editCertResponse = await this.doRequestApi(
|
||||
await this.doRequestApi(
|
||||
`${this.baseApi}/api/2.6/certificates`,
|
||||
{
|
||||
certificate: cert.crt,
|
||||
@@ -84,7 +87,7 @@ export class CacheFlyPlugin extends AbstractTaskPlugin {
|
||||
'post',
|
||||
token
|
||||
);
|
||||
this.logger.info('证书更新成功:', editCertResponse.message);
|
||||
this.logger.info('证书更新成功');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user