mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-08-21 16:23:42 +08:00
feat: add DISABLE_ADMIN_PASSWORD_CHECK (#386)
This commit is contained in:
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)
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user