mirror of
https://github.com/certimate-go/certimate.git
synced 2026-06-30 21:05:12 +08:00
Merge pull request #1058 from fudiwei:bugfix
This commit is contained in:
commit
87116f92cd
@ -23,6 +23,7 @@ func init() {
|
||||
AllowInsecureConnections: credentials.AllowInsecureConnections,
|
||||
NodeName: xmaps.GetString(options.ProviderExtendedConfig, "nodeName"),
|
||||
ResourceType: xmaps.GetString(options.ProviderExtendedConfig, "resourceType"),
|
||||
WebsiteMatchPattern: xmaps.GetString(options.ProviderExtendedConfig, "websiteMatchPattern"),
|
||||
WebsiteId: xmaps.GetInt64(options.ProviderExtendedConfig, "websiteId"),
|
||||
CertificateId: xmaps.GetInt64(options.ProviderExtendedConfig, "certificateId"),
|
||||
})
|
||||
|
||||
@ -81,7 +81,7 @@ func (c *Certmgr) Upload(ctx context.Context, certPEM, privkeyPEM string) (*cert
|
||||
// REF: https://learn.microsoft.com/en-us/rest/api/keyvault/certificates/get-certificates/get-certificates
|
||||
listCertificatesPager := c.sdkClient.NewListCertificatePropertiesPager(nil)
|
||||
for listCertificatesPager.More() {
|
||||
page, err := listCertificatesPager.NextPage(context.TODO())
|
||||
page, err := listCertificatesPager.NextPage(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to execute sdk request 'keyvault.GetCertificates': %w", err)
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"time"
|
||||
|
||||
"github.com/wneessen/go-mail"
|
||||
|
||||
@ -65,11 +66,12 @@ func (n *Notifier) Notify(ctx context.Context, subject string, message string) (
|
||||
mail.WithSMTPAuth(mail.SMTPAuthAutoDiscover),
|
||||
mail.WithUsername(n.config.Username),
|
||||
mail.WithPassword(n.config.Password),
|
||||
mail.WithTimeout(time.Second * 30),
|
||||
}
|
||||
|
||||
if n.config.SmtpPort == 0 {
|
||||
if n.config.SmtpTls {
|
||||
clientOptions = append(clientOptions, mail.WithPort(mail.DefaultPortTLS))
|
||||
clientOptions = append(clientOptions, mail.WithPort(mail.DefaultPortSSL))
|
||||
} else {
|
||||
clientOptions = append(clientOptions, mail.WithPort(mail.DefaultPort))
|
||||
}
|
||||
@ -85,11 +87,12 @@ func (n *Notifier) Notify(ctx context.Context, subject string, message string) (
|
||||
tlsConfig.ServerName = n.config.SmtpHost
|
||||
}
|
||||
|
||||
mail.WithSSL()
|
||||
mail.WithSSLPort(true)
|
||||
mail.WithTLSConfig(tlsConfig)
|
||||
clientOptions = append(clientOptions, mail.WithSSL())
|
||||
clientOptions = append(clientOptions, mail.WithTLSConfig(tlsConfig))
|
||||
clientOptions = append(clientOptions, mail.WithTLSPolicy(mail.TLSMandatory))
|
||||
} else {
|
||||
mail.WithTLSPolicy(mail.TLSOpportunistic)
|
||||
clientOptions = append(clientOptions, mail.WithSSLPort(true))
|
||||
clientOptions = append(clientOptions, mail.WithTLSPolicy(mail.TLSOpportunistic))
|
||||
}
|
||||
|
||||
client, err := mail.NewClient(n.config.SmtpHost, clientOptions...)
|
||||
|
||||
@ -174,7 +174,11 @@ const AccessEditDrawer = ({ afterSubmit, mode, data, loading, trigger, usage, ..
|
||||
title={
|
||||
<Flex align="center" justify="space-between" gap="small">
|
||||
<div className="flex-1 truncate">
|
||||
{mode === "modify" && !!data ? t("access.action.edit.modal.title") + ` #${data.id}` : t(`access.action.${mode}.modal.title`)}
|
||||
{mode === "modify"
|
||||
? data?.id
|
||||
? t("access.action.edit.modal.title") + ` #${data.id}`
|
||||
: t("access.action.edit.modal.title")
|
||||
: t(`access.action.${mode}.modal.title`)}
|
||||
</div>
|
||||
<Button
|
||||
className="ant-drawer-close"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { getI18n, useTranslation } from "react-i18next";
|
||||
import { Form, Input, InputNumber, Switch } from "antd";
|
||||
import { Form, Input, InputNumber, Select, Switch } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
@ -19,15 +19,7 @@ const AccessConfigFormFieldsProviderEmail = () => {
|
||||
const formInst = Form.useFormInstance();
|
||||
const initialValues = getInitialValues();
|
||||
|
||||
const fieldSmtpTLS = Form.useWatch<boolean>([parentNamePath, "smtpTls"], formInst);
|
||||
|
||||
const handleTlsSwitchChange = (checked: boolean) => {
|
||||
const oldPort = formInst.getFieldValue([parentNamePath, "smtpPort"]);
|
||||
const newPort = checked && (oldPort == null || oldPort === 25) ? 587 : !checked && (oldPort == null || oldPort === 587) ? 25 : oldPort;
|
||||
if (newPort !== oldPort) {
|
||||
formInst.setFieldValue([parentNamePath, "smtpPort"], newPort);
|
||||
}
|
||||
};
|
||||
const fieldSmtpTls = Form.useWatch<boolean>([parentNamePath, "smtpTls"], formInst);
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -55,15 +47,18 @@ const AccessConfigFormFieldsProviderEmail = () => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex space-x-2">
|
||||
<div className="w-1/2">
|
||||
<div className="flex space-x-8">
|
||||
<div className={fieldSmtpTls ? "w-1/2" : "w-3/5"}>
|
||||
<Form.Item name={[parentNamePath, "smtpTls"]} initialValue={initialValues.smtpTls} label={t("access.form.email_smtp_tls.label")} rules={[formRule]}>
|
||||
<Switch onChange={handleTlsSwitchChange} />
|
||||
<Select placeholder={t("access.form.email_smtp_tls.placeholder")}>
|
||||
<Select.Option value={true}>{t("access.form.email_smtp_tls.option.true.label")}</Select.Option>
|
||||
<Select.Option value={false}>{t("access.form.email_smtp_tls.option.false.label")}</Select.Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
<div className="w-1/2">
|
||||
<Show when={fieldSmtpTLS}>
|
||||
<Show when={fieldSmtpTls}>
|
||||
<div className="w-1/2">
|
||||
<Form.Item
|
||||
name={[parentNamePath, "allowInsecureConnections"]}
|
||||
initialValue={initialValues.allowInsecureConnections}
|
||||
@ -75,8 +70,8 @@ const AccessConfigFormFieldsProviderEmail = () => {
|
||||
unCheckedChildren={t("access.form.shared_allow_insecure_conns.switch.off")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Show>
|
||||
</div>
|
||||
</div>
|
||||
</Show>
|
||||
</div>
|
||||
|
||||
<Form.Item name={[parentNamePath, "username"]} initialValue={initialValues.username} label={t("access.form.email_username.label")} rules={[formRule]}>
|
||||
|
||||
@ -267,7 +267,10 @@
|
||||
"access.form.email_smtp_host.placeholder": "Please enter SMTP host",
|
||||
"access.form.email_smtp_port.label": "SMTP port",
|
||||
"access.form.email_smtp_port.placeholder": "Please enter SMTP port",
|
||||
"access.form.email_smtp_tls.label": "Use SSL/TLS",
|
||||
"access.form.email_smtp_tls.label": "Security connection",
|
||||
"access.form.email_smtp_tls.placeholder": "Please select security connection",
|
||||
"access.form.email_smtp_tls.option.true.label": "Force SSL/TLS connection",
|
||||
"access.form.email_smtp_tls.option.false.label": "Prefer STARTTLS, fallback to plain if failed",
|
||||
"access.form.email_username.label": "Username",
|
||||
"access.form.email_username.placeholder": "please enter username",
|
||||
"access.form.email_password.label": "Password",
|
||||
|
||||
@ -266,7 +266,10 @@
|
||||
"access.form.email_smtp_host.placeholder": "请输入 SMTP 服务器地址",
|
||||
"access.form.email_smtp_port.label": "SMTP 服务器端口",
|
||||
"access.form.email_smtp_port.placeholder": "请输入 SMTP 服务器端口",
|
||||
"access.form.email_smtp_tls.label": "SSL/TLS 连接",
|
||||
"access.form.email_smtp_tls.label": "连接安全性",
|
||||
"access.form.email_smtp_tls.placeholder": "请选择连接安全性",
|
||||
"access.form.email_smtp_tls.option.true.label": "强制 SSL/TLS 连接",
|
||||
"access.form.email_smtp_tls.option.false.label": "优先 STARTTLS,失败则回退为明文连接",
|
||||
"access.form.email_username.label": "用户名",
|
||||
"access.form.email_username.placeholder": "请输入用户名",
|
||||
"access.form.email_password.label": "密码",
|
||||
|
||||
@ -251,7 +251,7 @@ const CertificateList = () => {
|
||||
});
|
||||
},
|
||||
{
|
||||
refreshDeps: [filters, sorter, page, pageSize],
|
||||
refreshDeps: [expiryThreshold, filters, sorter, page, pageSize],
|
||||
onBefore: async () => {
|
||||
setSearchParams((prev) => {
|
||||
if (filters["keyword"]) {
|
||||
@ -274,7 +274,10 @@ const CertificateList = () => {
|
||||
|
||||
if (expiryThreshold === 0) {
|
||||
const settings = await getSettings(SETTINGS_NAMES.PERSISTENCE);
|
||||
setExpiryThreshold(settings?.content?.certificatesWarningDaysBeforeExpire ?? 0);
|
||||
const threshold = settings?.content?.certificatesWarningDaysBeforeExpire ?? 0;
|
||||
if (threshold !== expiryThreshold) {
|
||||
setExpiryThreshold(threshold);
|
||||
}
|
||||
}
|
||||
},
|
||||
onSuccess: (res) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user