mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-05-07 06:22:44 +08:00
feat: add DISABLE_ADMIN_PASSWORD_CHECK (#386)
This commit is contained in:
@@ -14,6 +14,7 @@ DB changes: 增加用户 `passkey` 表, 需要执行 `db/2024-08-10-patch.sql`
|
||||
- feat: worker 增加 `DISABLE_SHOW_GITHUB` 配置, 用于配置是否显示 github 链接
|
||||
- feat: worker 增加 `NO_LIMIT_SEND_ROLE` 配置, 用于配置可以无限发送邮件的角色
|
||||
- feat: 用户增加 `passkey` 登录方式, 用于用户登录, 无需输入密码
|
||||
- feat: worker 增加 `DISABLE_ADMIN_PASSWORD_CHECK` 配置, 用于配置是否禁用 admin 控制台密码检查, 若你的网站只可私人访问,可通过此禁用检查
|
||||
|
||||
## v0.6.1
|
||||
|
||||
|
||||
@@ -84,6 +84,8 @@ PREFIX = "tmp" # The mailbox name prefix to be processed
|
||||
# PASSWORDS = ["123", "456"]
|
||||
# admin console password, if not configured, access to the console is not allowed
|
||||
# ADMIN_PASSWORDS = ["123", "456"]
|
||||
# warning: no password or user check for admin portal
|
||||
# DISABLE_ADMIN_PASSWORD_CHECK = false
|
||||
# admin contact information. If not configured, it will not be displayed. Any string can be configured.
|
||||
# ADMIN_CONTACT = "xx@xx.xxx"
|
||||
DEFAULT_DOMAINS = ["xxx.xxx1" , "xxx.xxx2"] # domain name for no role users
|
||||
|
||||
@@ -52,6 +52,8 @@ PREFIX = "tmp" # 要处理的邮箱名称前缀,不需要后缀可配置为空
|
||||
# PASSWORDS = ["123", "456"]
|
||||
# admin 控制台密码, 不配置则不允许访问控制台
|
||||
# ADMIN_PASSWORDS = ["123", "456"]
|
||||
# 警告: 管理员控制台没有密码或用户检查
|
||||
# DISABLE_ADMIN_PASSWORD_CHECK = false
|
||||
# admin 联系方式,不配置则不显示,可配置任意字符串
|
||||
# ADMIN_CONTACT = "xx@xx.xxx"
|
||||
# DEFAULT_DOMAINS = ["xxx.xxx1" , "xxx.xxx2"] # 默认用户可用的域名(未登录或未分配角色的用户)
|
||||
|
||||
@@ -9,3 +9,7 @@
|
||||
需要在后端配置 `ADMIN_PASSWORDS` 或者当前用户角色为 `ADMIN_USER_ROLE`, 则不允许访问控制台。
|
||||
|
||||

|
||||
|
||||
## 如果你的网站只可私人访问,可通过此禁用检查
|
||||
|
||||
`DISABLE_ADMIN_PASSWORD_CHECK = true`
|
||||
|
||||
1
worker/src/types.d.ts
vendored
1
worker/src/types.d.ts
vendored
@@ -25,6 +25,7 @@ export type Bindings = {
|
||||
DOMAIN_LABELS: string | string[] | undefined
|
||||
PASSWORDS: string | string[] | undefined
|
||||
ADMIN_PASSWORDS: string | string[] | undefined
|
||||
DISABLE_ADMIN_PASSWORD_CHECK: string | boolean | undefined
|
||||
JWT_SECRET: string
|
||||
BLACK_LIST: string | undefined
|
||||
ENABLE_AUTO_REPLY: string | boolean | undefined
|
||||
|
||||
@@ -153,6 +153,7 @@ app.use('/user_api/*', async (c, next) => {
|
||||
});
|
||||
// admin auth
|
||||
app.use('/admin/*', async (c, next) => {
|
||||
|
||||
// check header x-admin-auth
|
||||
const adminPasswords = getAdminPasswords(c);
|
||||
if (adminPasswords && adminPasswords.length > 0) {
|
||||
@@ -182,6 +183,13 @@ app.use('/admin/*', async (c, next) => {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
// disable admin api check
|
||||
if (getBooleanValue(c.env.DISABLE_ADMIN_PASSWORD_CHECK)) {
|
||||
await next();
|
||||
return;
|
||||
}
|
||||
|
||||
return c.text("Need Admin Password", 401)
|
||||
});
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ PREFIX = "tmp"
|
||||
# PASSWORDS = ["123", "456"]
|
||||
# For admin panel
|
||||
# ADMIN_PASSWORDS = ["123", "456"]
|
||||
# warning: no password or user check for admin portal
|
||||
# DISABLE_ADMIN_PASSWORD_CHECK = false
|
||||
# ADMIN CONTACT, CAN BE ANY STRING
|
||||
# ADMIN_CONTACT = "xx@xx.xxx"
|
||||
DEFAULT_DOMAINS = ["xxx.xxx1" , "xxx.xxx2"] # domain name for no role users
|
||||
|
||||
Reference in New Issue
Block a user