mirror of
https://github.com/woodchen-ink/certimate.git
synced 2025-07-18 09:21:56 +08:00
feat: add vercel dns-01 applicant
This commit is contained in:
parent
fb325b5447
commit
ad0125fe0d
@ -30,6 +30,7 @@ import (
|
||||
pPowerDNS "github.com/usual2970/certimate/internal/pkg/core/applicant/acme-dns-01/lego-providers/powerdns"
|
||||
pRainYun "github.com/usual2970/certimate/internal/pkg/core/applicant/acme-dns-01/lego-providers/rainyun"
|
||||
pTencentCloud "github.com/usual2970/certimate/internal/pkg/core/applicant/acme-dns-01/lego-providers/tencentcloud"
|
||||
pVercel "github.com/usual2970/certimate/internal/pkg/core/applicant/acme-dns-01/lego-providers/vercel"
|
||||
pVolcEngine "github.com/usual2970/certimate/internal/pkg/core/applicant/acme-dns-01/lego-providers/volcengine"
|
||||
pWestcn "github.com/usual2970/certimate/internal/pkg/core/applicant/acme-dns-01/lego-providers/westcn"
|
||||
"github.com/usual2970/certimate/internal/pkg/utils/maputil"
|
||||
@ -425,6 +426,22 @@ func createApplicant(options *applicantOptions) (challenge.Provider, error) {
|
||||
return applicant, err
|
||||
}
|
||||
|
||||
case domain.ApplyDNSProviderTypeVercel:
|
||||
{
|
||||
access := domain.AccessConfigForVercel{}
|
||||
if err := maputil.Populate(options.ProviderAccessConfig, &access); err != nil {
|
||||
return nil, fmt.Errorf("failed to populate provider access config: %w", err)
|
||||
}
|
||||
|
||||
applicant, err := pVercel.NewChallengeProvider(&pVercel.ChallengeProviderConfig{
|
||||
ApiAccessToken: access.ApiAccessToken,
|
||||
TeamId: access.TeamId,
|
||||
DnsPropagationTimeout: options.DnsPropagationTimeout,
|
||||
DnsTTL: options.DnsTTL,
|
||||
})
|
||||
return applicant, err
|
||||
}
|
||||
|
||||
case domain.ApplyDNSProviderTypeVolcEngine, domain.ApplyDNSProviderTypeVolcEngineDNS:
|
||||
{
|
||||
access := domain.AccessConfigForVolcEngine{}
|
||||
|
@ -219,6 +219,11 @@ type AccessConfigForUpyun struct {
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
type AccessConfigForVercel struct {
|
||||
ApiAccessToken string `json:"apiAccessToken"`
|
||||
TeamId string `json:"teamId,omitempty"`
|
||||
}
|
||||
|
||||
type AccessConfigForVolcEngine struct {
|
||||
AccessKeyId string `json:"accessKeyId"`
|
||||
SecretAccessKey string `json:"secretAccessKey"`
|
||||
|
@ -54,7 +54,7 @@ const (
|
||||
AccessProviderTypeTencentCloud = AccessProviderType("tencentcloud")
|
||||
AccessProviderTypeUCloud = AccessProviderType("ucloud")
|
||||
AccessProviderTypeUpyun = AccessProviderType("upyun")
|
||||
AccessProviderTypeVercel = AccessProviderType("vercel") // Vercel(预留)
|
||||
AccessProviderTypeVercel = AccessProviderType("vercel")
|
||||
AccessProviderTypeVolcEngine = AccessProviderType("volcengine")
|
||||
AccessProviderTypeWebhook = AccessProviderType("webhook")
|
||||
AccessProviderTypeWestcn = AccessProviderType("westcn")
|
||||
|
@ -0,0 +1,38 @@
|
||||
package vercel
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v4/challenge"
|
||||
"github.com/go-acme/lego/v4/providers/dns/vercel"
|
||||
)
|
||||
|
||||
type ChallengeProviderConfig struct {
|
||||
ApiAccessToken string `json:"apiAccessToken"`
|
||||
TeamId string `json:"teamId,omitempty"`
|
||||
DnsPropagationTimeout int32 `json:"dnsPropagationTimeout,omitempty"`
|
||||
DnsTTL int32 `json:"dnsTTL,omitempty"`
|
||||
}
|
||||
|
||||
func NewChallengeProvider(config *ChallengeProviderConfig) (challenge.Provider, error) {
|
||||
if config == nil {
|
||||
panic("config is nil")
|
||||
}
|
||||
|
||||
providerConfig := vercel.NewDefaultConfig()
|
||||
providerConfig.AuthToken = config.ApiAccessToken
|
||||
providerConfig.TeamID = config.TeamId
|
||||
if config.DnsPropagationTimeout != 0 {
|
||||
providerConfig.PropagationTimeout = time.Duration(config.DnsPropagationTimeout) * time.Second
|
||||
}
|
||||
if config.DnsTTL != 0 {
|
||||
providerConfig.TTL = int(config.DnsTTL)
|
||||
}
|
||||
|
||||
provider, err := vercel.NewDNSProviderConfig(providerConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return provider, nil
|
||||
}
|
1
ui/public/imgs/providers/vercel.svg
Normal file
1
ui/public/imgs/providers/vercel.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M512 60l512 904H0z" fill="#212121" p-id="6434"></path></svg>
|
After Width: | Height: | Size: 216 B |
@ -48,6 +48,7 @@ import AccessFormSSHConfig from "./AccessFormSSHConfig";
|
||||
import AccessFormTencentCloudConfig from "./AccessFormTencentCloudConfig";
|
||||
import AccessFormUCloudConfig from "./AccessFormUCloudConfig";
|
||||
import AccessFormUpyunConfig from "./AccessFormUpyunConfig";
|
||||
import AccessFormVercelConfig from "./AccessFormVercelConfig";
|
||||
import AccessFormVolcEngineConfig from "./AccessFormVolcEngineConfig";
|
||||
import AccessFormWebhookConfig from "./AccessFormWebhookConfig";
|
||||
import AccessFormWestcnConfig from "./AccessFormWestcnConfig";
|
||||
@ -182,6 +183,8 @@ const AccessForm = forwardRef<AccessFormInstance, AccessFormProps>(({ className,
|
||||
return <AccessFormUCloudConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.UPYUN:
|
||||
return <AccessFormUpyunConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.VERCEL:
|
||||
return <AccessFormVercelConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.VOLCENGINE:
|
||||
return <AccessFormVolcEngineConfig {...nestedFormProps} />;
|
||||
case ACCESS_PROVIDERS.WEBHOOK:
|
||||
|
@ -28,9 +28,9 @@ const AccessFormUCloudConfig = ({ form: formInst, formName, disabled, initialVal
|
||||
const formSchema = z.object({
|
||||
privateKey: z
|
||||
.string()
|
||||
.trim()
|
||||
.min(1, t("access.form.ucloud_private_key.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 }))
|
||||
.trim(),
|
||||
publicKey: z
|
||||
.string()
|
||||
.min(1, t("access.form.ucloud_public_key.placeholder"))
|
||||
|
75
ui/src/components/access/AccessFormVercelConfig.tsx
Normal file
75
ui/src/components/access/AccessFormVercelConfig.tsx
Normal file
@ -0,0 +1,75 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, type FormInstance, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
import { type AccessConfigForVercel } from "@/domain/access";
|
||||
|
||||
type AccessFormVercelConfigFieldValues = Nullish<AccessConfigForVercel>;
|
||||
|
||||
export type AccessFormVercelConfigProps = {
|
||||
form: FormInstance;
|
||||
formName: string;
|
||||
disabled?: boolean;
|
||||
initialValues?: AccessFormVercelConfigFieldValues;
|
||||
onValuesChange?: (values: AccessFormVercelConfigFieldValues) => void;
|
||||
};
|
||||
|
||||
const initFormModel = (): AccessFormVercelConfigFieldValues => {
|
||||
return {
|
||||
apiAccessToken: "",
|
||||
};
|
||||
};
|
||||
|
||||
const AccessFormVercelConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormVercelConfigProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
apiAccessToken: z
|
||||
.string()
|
||||
.min(1, t("access.form.vercel_api_access_token.placeholder"))
|
||||
.max(256, t("common.errmsg.string_max", { max: 256 }))
|
||||
.trim(),
|
||||
teamId: z
|
||||
.string()
|
||||
.max(256, t("common.errmsg.string_max", { max: 256 }))
|
||||
.trim()
|
||||
.nullish(),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
|
||||
onValuesChange?.(values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={formInst}
|
||||
disabled={disabled}
|
||||
initialValues={initialValues ?? initFormModel()}
|
||||
layout="vertical"
|
||||
name={formName}
|
||||
onValuesChange={handleFormChange}
|
||||
>
|
||||
<Form.Item
|
||||
name="apiAccessToken"
|
||||
label={t("access.form.vercel_api_access_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.vercel_api_access_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input.Password autoComplete="new-password" placeholder={t("access.form.vercel_api_access_token.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="teamId"
|
||||
label={t("access.form.vercel_team_id.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.vercel_team_id.tooltip") }}></span>}
|
||||
>
|
||||
<Input placeholder={t("access.form.vercel_team_id.placeholder")} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccessFormVercelConfig;
|
@ -28,9 +28,9 @@ const AccessFormVolcEngineConfig = ({ form: formInst, formName, disabled, initia
|
||||
const formSchema = z.object({
|
||||
accessKeyId: z
|
||||
.string()
|
||||
.trim()
|
||||
.min(1, t("access.form.volcengine_access_key_id.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 }))
|
||||
.trim(),
|
||||
secretAccessKey: z
|
||||
.string()
|
||||
.min(1, t("access.form.volcengine_secret_access_key.placeholder"))
|
||||
|
@ -28,9 +28,9 @@ const AccessFormWestcnConfig = ({ form: formInst, formName, disabled, initialVal
|
||||
const formSchema = z.object({
|
||||
username: z
|
||||
.string()
|
||||
.trim()
|
||||
.min(1, t("access.form.westcn_username.placeholder"))
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 })),
|
||||
.max(64, t("common.errmsg.string_max", { max: 64 }))
|
||||
.trim(),
|
||||
apiPassword: z
|
||||
.string()
|
||||
.min(1, t("access.form.westcn_api_password.placeholder"))
|
||||
|
@ -44,6 +44,7 @@ export interface AccessModel extends BaseModel {
|
||||
| AccessConfigForTencentCloud
|
||||
| AccessConfigForUCloud
|
||||
| AccessConfigForUpyun
|
||||
| AccessConfigForVercel
|
||||
| AccessConfigForVolcEngine
|
||||
| AccessConfigForWebhook
|
||||
| AccessConfigForWestcn
|
||||
@ -246,6 +247,11 @@ export type AccessConfigForUpyun = {
|
||||
password: string;
|
||||
};
|
||||
|
||||
export type AccessConfigForVercel = {
|
||||
apiAccessToken: string;
|
||||
teamId?: string;
|
||||
};
|
||||
|
||||
export type AccessConfigForVolcEngine = {
|
||||
accessKeyId: string;
|
||||
secretAccessKey: string;
|
||||
|
@ -110,6 +110,7 @@ export const accessProvidersMap: Map<AccessProvider["type"] | string, AccessProv
|
||||
[ACCESS_PROVIDERS.NAMESILO, "provider.namesilo", "/imgs/providers/namesilo.svg", [ACCESS_USAGES.APPLY]],
|
||||
[ACCESS_PROVIDERS.NS1, "provider.ns1", "/imgs/providers/ns1.svg", [ACCESS_USAGES.APPLY]],
|
||||
[ACCESS_PROVIDERS.PORKBUN, "provider.porkbun", "/imgs/providers/porkbun.svg", [ACCESS_USAGES.APPLY]],
|
||||
[ACCESS_PROVIDERS.VERCEL, "provider.vercel", "/imgs/providers/vercel.svg", [ACCESS_USAGES.APPLY]],
|
||||
[ACCESS_PROVIDERS.CMCCCLOUD, "provider.cmcccloud", "/imgs/providers/cmcccloud.svg", [ACCESS_USAGES.APPLY]],
|
||||
[ACCESS_PROVIDERS.RAINYUN, "provider.rainyun", "/imgs/providers/rainyun.svg", [ACCESS_USAGES.APPLY]],
|
||||
[ACCESS_PROVIDERS.WESTCN, "provider.westcn", "/imgs/providers/westcn.svg", [ACCESS_USAGES.APPLY]],
|
||||
@ -206,6 +207,7 @@ export const applyDNSProvidersMap: Map<ApplyDNSProvider["type"] | string, ApplyD
|
||||
[APPLY_DNS_PROVIDERS.NAMESILO, "provider.namesilo"],
|
||||
[APPLY_DNS_PROVIDERS.NS1, "provider.ns1"],
|
||||
[APPLY_DNS_PROVIDERS.PORKBUN, "provider.porkbun"],
|
||||
[APPLY_DNS_PROVIDERS.VERCEL, "provider.vercel"],
|
||||
[APPLY_DNS_PROVIDERS.CMCCCLOUD, "provider.cmcc"],
|
||||
[APPLY_DNS_PROVIDERS.RAINYUN, "provider.rainyun"],
|
||||
[APPLY_DNS_PROVIDERS.WESTCN, "provider.westcn"],
|
||||
|
@ -261,6 +261,12 @@
|
||||
"access.form.ucloud_project_id.label": "UCloud project ID (Optional)",
|
||||
"access.form.ucloud_project_id.placeholder": "Please enter UCloud project ID",
|
||||
"access.form.ucloud_project_id.tooltip": "For more information, see <a href=\"https://console.ucloud-global.com/uaccount/iam/project_manage\" target=\"_blank\">https://console.ucloud-global.com/uaccount/iam/project_manage</a>",
|
||||
"access.form.vercel_api_access_token.label": "Vercel API access token",
|
||||
"access.form.vercel_api_access_token.placeholder": "Please enter Vercel API access token",
|
||||
"access.form.vercel_api_access_token.tooltip": "For more information, see <a href=\"https://vercel.com/guides/how-do-i-use-a-vercel-api-access-token\" target=\"_blank\">https://vercel.com/guides/how-do-i-use-a-vercel-api-access-token</a>",
|
||||
"access.form.vercel_team_id.label": "Vercel team ID (Optional)",
|
||||
"access.form.vercel_team_id.placeholder": "Please enter Vercel team ID",
|
||||
"access.form.vercel_team_id.tooltip": "For more information, see <a href=\"https://vercel.com/docs/accounts#find-your-team-id\" target=\"_blank\">https://vercel.com/docs/accounts#find-your-team-id</a>",
|
||||
"access.form.volcengine_access_key_id.label": "VolcEngine AccessKeyId",
|
||||
"access.form.volcengine_access_key_id.placeholder": "Please enter VolcEngine AccessKeyId",
|
||||
"access.form.volcengine_access_key_id.tooltip": "For more information, see <a href=\"https://www.volcengine.com/docs/6291/216571\" target=\"_blank\">https://www.volcengine.com/docs/6291/216571</a>",
|
||||
|
@ -261,6 +261,12 @@
|
||||
"access.form.upyun_password.label": "又拍云子账号密码",
|
||||
"access.form.upyun_password.placeholder": "请输入又拍云子账号密码",
|
||||
"access.form.upyun_password.tooltip": "这是什么?请参阅 <a href=\"https://console.upyun.com/account/subaccount/\" target=\"_blank\">https://console.upyun.com/account/subaccount/</a><br><br>请关闭该账号的二次登录验证。",
|
||||
"access.form.vercel_api_access_token.label": "Vercel API Access Token",
|
||||
"access.form.vercel_api_access_token.placeholder": "请输入 Vercel API Access Token",
|
||||
"access.form.vercel_api_access_token.tooltip": "这是什么?请参阅 <a href=\"https://vercel.com/guides/how-do-i-use-a-vercel-api-access-token\" target=\"_blank\">https://vercel.com/guides/how-do-i-use-a-vercel-api-access-token</a>",
|
||||
"access.form.vercel_team_id.label": "Vercel 团队 ID(可选)",
|
||||
"access.form.vercel_team_id.placeholder": "请输入 Vercel 团队 ID",
|
||||
"access.form.vercel_team_id.tooltip": "这是什么?请参阅 <a href=\"https://vercel.com/docs/accounts#find-your-team-id\" target=\"_blank\">https://vercel.com/docs/accounts#find-your-team-id</a>",
|
||||
"access.form.volcengine_access_key_id.label": "火山引擎 AccessKeyId",
|
||||
"access.form.volcengine_access_key_id.placeholder": "请输入火山引擎 AccessKeyId",
|
||||
"access.form.volcengine_access_key_id.tooltip": "这是什么?请参阅 <a href=\"https://www.volcengine.com/docs/6291/216571\" target=\"_blank\">https://www.volcengine.com/docs/6291/216571</a>",
|
||||
|
Loading…
x
Reference in New Issue
Block a user