+
+
+ {{ t('save') }}
+
+
-
+
@@ -103,7 +110,13 @@ onMounted(async () => {
+ :placeholder="t('mailAllowList')">
+
+
+ {{ t('manualInputPrompt') }}
+
+
+
@@ -112,9 +125,6 @@ onMounted(async () => {
:placeholder="t('maxAddressCount')" />
-
- {{ t('save') }}
-
diff --git a/frontend/src/views/admin/Webhook.vue b/frontend/src/views/admin/Webhook.vue
index 15c21d90..0d31dc47 100644
--- a/frontend/src/views/admin/Webhook.vue
+++ b/frontend/src/views/admin/Webhook.vue
@@ -13,13 +13,17 @@ const { t } = useI18n({
messages: {
en: {
successTip: 'Success',
- webhookAllowList: 'Webhook Allow List(Enter the address that is allowed to use webhook and enter)',
+ enableAllowList: 'Enable Allow List (Restrict webhook access to specific users)',
+ webhookAllowList: 'Webhook Allow List(Enter the mail address that is allowed to use webhook and enter)',
+ manualInputPrompt: 'Type and press Enter to add',
save: 'Save',
notEnabled: 'Webhook is not enabled',
},
zh: {
successTip: '成功',
- webhookAllowList: 'Webhook 白名单(请输入允许使用webhook 的地址, 回车增加)',
+ enableAllowList: '启用白名单 (限制 webhook 访问权限,只有白名单中的用户可以使用)',
+ webhookAllowList: 'Webhook 白名单(请输入允许使用webhook 的邮箱地址, 回车增加)',
+ manualInputPrompt: '输入后按回车键添加',
save: '保存',
notEnabled: 'Webhook 未开启',
}
@@ -27,14 +31,16 @@ const { t } = useI18n({
});
class WebhookSettings {
+ enableAllowList: boolean;
allowList: string[];
- constructor(allowList: string[]) {
+ constructor(enableAllowList: boolean, allowList: string[]) {
+ this.enableAllowList = enableAllowList;
this.allowList = allowList;
}
}
-const webhookSettings = ref(new WebhookSettings([]))
+const webhookSettings = ref(new WebhookSettings(false, []))
const webhookEnabled = ref(false)
const errorInfo = ref('')
@@ -68,13 +74,24 @@ onMounted(async () => {
+
+
+ {{ t('save') }}
+
+
+
+
+
+ :placeholder="t('webhookAllowList')">
+
+
+ {{ t('manualInputPrompt') }}
+
+
+
-
- {{ t('save') }}
-
diff --git a/frontend/src/views/admin/WorkerConfig.vue b/frontend/src/views/admin/WorkerConfig.vue
index 564c6585..a401e702 100644
--- a/frontend/src/views/admin/WorkerConfig.vue
+++ b/frontend/src/views/admin/WorkerConfig.vue
@@ -26,7 +26,7 @@ onMounted(async () => {
-
+
{{ JSON.stringify(settings, null, 2) }}
diff --git a/worker/src/admin_api/webhook_settings.ts b/worker/src/admin_api/webhook_settings.ts
index 38035dce..3b415f91 100644
--- a/worker/src/admin_api/webhook_settings.ts
+++ b/worker/src/admin_api/webhook_settings.ts
@@ -4,7 +4,7 @@ import { AdminWebhookSettings } from "../models";
async function getWebhookSettings(c: Context): Promise {
const settings = await c.env.KV.get(CONSTANTS.WEBHOOK_KV_SETTINGS_KEY, "json");
- return c.json(settings || new AdminWebhookSettings([]));
+ return c.json(settings || new AdminWebhookSettings(false, []));
}
async function saveWebhookSettings(c: Context): Promise {
diff --git a/worker/src/common.ts b/worker/src/common.ts
index 07652a84..475ac950 100644
--- a/worker/src/common.ts
+++ b/worker/src/common.ts
@@ -480,7 +480,7 @@ export async function triggerWebhook(
// user mail webhook
const adminSettings = await c.env.KV.get(CONSTANTS.WEBHOOK_KV_SETTINGS_KEY, "json");
- if (adminSettings?.allowList.includes(address)) {
+ if (!adminSettings?.enableAllowList || adminSettings?.allowList.includes(address)) {
const settings = await c.env.KV.get(
`${CONSTANTS.WEBHOOK_KV_USER_SETTINGS_KEY}:${address}`, "json"
);
diff --git a/worker/src/mails_api/webhook_settings.ts b/worker/src/mails_api/webhook_settings.ts
index 87402c14..4e016d78 100644
--- a/worker/src/mails_api/webhook_settings.ts
+++ b/worker/src/mails_api/webhook_settings.ts
@@ -7,7 +7,7 @@ import { commonParseMail, sendWebhook } from "../common";
async function getWebhookSettings(c: Context): Promise {
const { address } = c.get("jwtPayload")
const adminSettings = await c.env.KV.get(CONSTANTS.WEBHOOK_KV_SETTINGS_KEY, "json");
- if (!adminSettings?.allowList.includes(address)) {
+ if (adminSettings?.enableAllowList && !adminSettings?.allowList.includes(address)) {
return c.text("Webhook settings is not allowed for this user", 403);
}
const settings = await c.env.KV.get(
@@ -20,7 +20,7 @@ async function getWebhookSettings(c: Context): Promise
async function saveWebhookSettings(c: Context): Promise {
const { address } = c.get("jwtPayload")
const adminSettings = await c.env.KV.get(CONSTANTS.WEBHOOK_KV_SETTINGS_KEY, "json");
- if (!adminSettings?.allowList.includes(address)) {
+ if (adminSettings?.enableAllowList && !adminSettings?.allowList.includes(address)) {
return c.text("Webhook settings is not allowed for this user", 403);
}
const settings = await c.req.json();
diff --git a/worker/src/models/index.ts b/worker/src/models/index.ts
index 94d54c3d..4b3ea628 100644
--- a/worker/src/models/index.ts
+++ b/worker/src/models/index.ts
@@ -14,9 +14,11 @@ export type Passkey = {
};
export class AdminWebhookSettings {
+ enableAllowList: boolean;
allowList: string[];
- constructor(allowList: string[]) {
+ constructor(enableAllowList: boolean, allowList: string[]) {
+ this.enableAllowList = enableAllowList;
this.allowList = allowList;
}
}