feat: update access fields to ApiToken and ApiTokenForZone for cloudflare services

This commit is contained in:
Fu Diwei
2026-06-04 18:55:48 +08:00
committed by RHQYZ
parent 6c9de9a8db
commit ed9f5b3322
7 changed files with 69 additions and 48 deletions
@@ -17,8 +17,8 @@ func init() {
}
provider, err := chlgimpl.NewChallenger(&chlgimpl.ChallengerConfig{
DnsApiToken: credentials.DnsApiToken,
ZoneApiToken: credentials.ZoneApiToken,
ApiToken: credentials.ApiToken,
ApiTokenForZone: credentials.ApiTokenForZone,
DnsPropagationTimeout: options.DnsPropagationTimeout,
DnsTTL: options.DnsTTL,
})
+2 -2
View File
@@ -152,8 +152,8 @@ type AccessConfigForCdnfly struct {
}
type AccessConfigForCloudflare struct {
DnsApiToken string `json:"dnsApiToken"`
ZoneApiToken string `json:"zoneApiToken,omitempty"`
ApiToken string `json:"apiToken"`
ApiTokenForZone string `json:"apiTokenForZone,omitempty"`
}
type AccessConfigForClouDNS struct {
@@ -33,25 +33,44 @@ func init() {
}
switch provider {
case "byteplus":
if _, ok := config["accessKey"]; ok {
config["accessKeyId"] = config["accessKey"]
delete(config, "accessKey")
record.Set("config", config)
changed = true
case "cloudflare":
{
if _, ok := config["dnsApiToken"]; ok {
config["apiToken"] = config["dnsApiToken"]
delete(config, "dnsApiToken")
record.Set("config", config)
changed = true
}
if _, ok := config["zoneApiToken"]; ok {
config["apiTokenForZone"] = config["zoneApiToken"]
delete(config, "zoneApiToken")
record.Set("config", config)
changed = true
}
}
if _, ok := config["secretKey"]; ok {
config["secretAccessKey"] = config["secretKey"]
delete(config, "secretKey")
record.Set("config", config)
changed = true
case "byteplus":
{
if _, ok := config["accessKey"]; ok {
config["accessKeyId"] = config["accessKey"]
delete(config, "accessKey")
record.Set("config", config)
changed = true
}
if _, ok := config["secretKey"]; ok {
config["secretAccessKey"] = config["secretKey"]
delete(config, "secretKey")
record.Set("config", config)
changed = true
}
}
case "volcengine":
if _, ok := config["accessKeySecret"]; ok {
config["secretAccessKey"] = config["accessKeySecret"]
delete(config, "accessKeySecret")
record.Set("config", config)
changed = true
{
if _, ok := config["accessKeySecret"]; ok {
config["secretAccessKey"] = config["accessKeySecret"]
delete(config, "accessKeySecret")
record.Set("config", config)
changed = true
}
}
}
@@ -10,8 +10,8 @@ import (
)
type ChallengerConfig struct {
DnsApiToken string `json:"dnsApiToken"`
ZoneApiToken string `json:"zoneApiToken,omitempty"`
ApiToken string `json:"apiToken"`
ApiTokenForZone string `json:"apiTokenForZone,omitempty"`
DnsPropagationTimeout int `json:"dnsPropagationTimeout,omitempty"`
DnsTTL int `json:"dnsTTL,omitempty"`
}
@@ -22,8 +22,10 @@ func NewChallenger(config *ChallengerConfig) (core.ACMEChallenger, error) {
}
providerConfig := cloudflare.NewDefaultConfig()
providerConfig.AuthToken = config.DnsApiToken
providerConfig.ZoneToken = config.ZoneApiToken
providerConfig.AuthToken = config.ApiToken
if config.ApiTokenForZone != "" {
providerConfig.ZoneToken = config.ApiTokenForZone
}
if config.DnsPropagationTimeout != 0 {
providerConfig.PropagationTimeout = time.Duration(config.DnsPropagationTimeout) * time.Second
}
@@ -18,24 +18,24 @@ const AccessConfigFormFieldsProviderCloudflare = () => {
return (
<>
<Form.Item
name={[parentNamePath, "dnsApiToken"]}
initialValue={initialValues.dnsApiToken}
label={t("access.form.cloudflare_dns_api_token.label")}
name={[parentNamePath, "apiToken"]}
initialValue={initialValues.apiToken}
label={t("access.form.cloudflare_api_token.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.cloudflare_dns_api_token.tooltip") }}></span>}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.cloudflare_api_token.tooltip") }}></span>}
>
<Input.Password autoComplete="new-password" placeholder={t("access.form.cloudflare_dns_api_token.placeholder")} />
<Input.Password autoComplete="new-password" placeholder={t("access.form.cloudflare_api_token.placeholder")} />
</Form.Item>
<Form.Item
name={[parentNamePath, "zoneApiToken"]}
initialValue={initialValues.zoneApiToken}
label={t("access.form.cloudflare_zone_api_token.label")}
extra={<span dangerouslySetInnerHTML={{ __html: t("access.form.cloudflare_zone_api_token.help") }}></span>}
name={[parentNamePath, "apiTokenForZone"]}
initialValue={initialValues.apiTokenForZone}
label={t("access.form.cloudflare_api_token_for_zone.label")}
extra={<span dangerouslySetInnerHTML={{ __html: t("access.form.cloudflare_api_token_for_zone.help") }}></span>}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.cloudflare_zone_api_token.tooltip") }}></span>}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.cloudflare_api_token_for_zone.tooltip") }}></span>}
>
<Input.Password allowClear autoComplete="new-password" placeholder={t("access.form.cloudflare_zone_api_token.placeholder")} />
<Input.Password allowClear autoComplete="new-password" placeholder={t("access.form.cloudflare_api_token_for_zone.placeholder")} />
</Form.Item>
</>
);
@@ -43,7 +43,7 @@ const AccessConfigFormFieldsProviderCloudflare = () => {
const getInitialValues = (): Nullish<z.infer<ReturnType<typeof getSchema>>> => {
return {
dnsApiToken: "",
apiToken: "",
};
};
@@ -51,8 +51,8 @@ const getSchema = ({ i18n = getI18n() }: { i18n: ReturnType<typeof getI18n> }) =
const { t: _ } = i18n;
return z.object({
dnsApiToken: z.string().nonempty(),
zoneApiToken: z.string().nullish(),
apiToken: z.string().nonempty(),
apiTokenForZone: z.string().nullish(),
});
};
+5 -5
View File
@@ -360,15 +360,15 @@
"placeholder": "Please enter Cdnfly user API secret",
"tooltip": "For more information, see <a href=\"https://doc.cdnfly.cn/shiyongjieshao.html\" target=\"_blank\">https://doc.cdnfly.cn/shiyongjieshao.html</a>"
},
"cloudflare_dns_api_token": {
"label": "Cloudflare DNS API token",
"placeholder": "Please enter Cloudflare DNS API token",
"cloudflare_api_token": {
"label": "Cloudflare API token",
"placeholder": "Please enter Cloudflare API token",
"tooltip": "For more information, see <a href=\"https://developers.cloudflare.com/fundamentals/api/get-started/create-token/\" target=\"_blank\">https://developers.cloudflare.com/fundamentals/api/get-started/create-token/</a>"
},
"cloudflare_zone_api_token": {
"cloudflare_api_token_for_zone": {
"label": "Cloudflare Zone API token (Optional)",
"placeholder": "Please enter Cloudflare Zone API token",
"help": "Notes: Only required when you scope the DNS API token to <b>specific zones</b>. PLease scope the Zone API token to <b>all zones</b> with <i>Zone/Zone/Read</i> permission.",
"help": "Notes: Only required when you scope the API token to <b>specific zones</b>. PLease scope the Zone API token to <b>all zones</b> with <i>Zone/Zone/Read</i> permission.",
"tooltip": "For more information, see <a href=\"https://developers.cloudflare.com/fundamentals/api/get-started/create-token/\" target=\"_blank\">https://developers.cloudflare.com/fundamentals/api/get-started/create-token/</a>"
},
"cloudns_auth_id": {
+5 -5
View File
@@ -358,15 +358,15 @@
"placeholder": "请输入 Cdnfly 用户端 API Secret",
"tooltip": "这是什么?请参阅 <a href=\"https://doc.cdnfly.cn/shiyongjieshao.html\" target=\"_blank\">https://doc.cdnfly.cn/shiyongjieshao.html</a>"
},
"cloudflare_dns_api_token": {
"label": "Cloudflare DNS API 令牌",
"placeholder": "请输入 Cloudflare DNS API 令牌",
"cloudflare_api_token": {
"label": "Cloudflare API 令牌",
"placeholder": "请输入 Cloudflare API 令牌",
"tooltip": "这是什么?请参阅 <a href=\"https://developers.cloudflare.com/fundamentals/api/get-started/create-token/\" target=\"_blank\">https://developers.cloudflare.com/fundamentals/api/get-started/create-token/</a>"
},
"cloudflare_zone_api_token": {
"cloudflare_api_token_for_zone": {
"label": "Cloudflare Zone API 令牌(可选)",
"placeholder": "请输入 Cloudflare Zone API 令牌",
"help": "提示:仅当你将 DNS API 令牌范围指定为<b>特定域</b>时需要填写,请将 Zone API 令牌范围指定为<b>全部域</b>,并分配 <i>Zone/Zone/Read</i> 权限。",
"help": "提示:仅当你将 API 令牌范围指定为<b>特定域</b>时需要填写,请将 Zone API 令牌范围指定为<b>全部域</b>,并分配 <i>Zone/Zone/Read</i> 权限。",
"tooltip": "这是什么?请参阅 <a href=\"https://developers.cloudflare.com/fundamentals/api/get-started/create-token/\" target=\"_blank\">https://developers.cloudflare.com/fundamentals/api/get-started/create-token/</a>"
},
"cloudns_auth_id": {