feat: add admin API IP whitelist (#1131)

* feat: add admin API IP whitelist

* fix: harden admin IP whitelist checks
This commit is contained in:
Dream Hunter
2026-09-02 01:21:24 +08:00
committed by GitHub
parent 5fd181d9c0
commit 3c505db9d0
12 changed files with 35 additions and 3 deletions
@@ -67,6 +67,8 @@ JWT_SECRET = "xxx"
# Admin console password, if not configured, console access is not allowed
# ADMIN_PASSWORDS = ["123", "456"]
# Admin API IP whitelist; applies to admin-password and Admin user-token access
# ADMIN_API_IP_WHITELIST = ["203.0.113.10"]
# Whether to allow users to create emails, not allowed if not configured
ENABLE_USER_CREATE_EMAIL = true
@@ -23,8 +23,11 @@
| Variable Name | Type | Description | Example |
| ------------------------------ | --------- | ------------------------------------------------------- | ---------------- |
| `PASSWORDS` | JSON | Website private passwords, required after configuration | `["123", "456"]` |
| `ADMIN_API_IP_WHITELIST` | JSON | Admin API IP whitelist; when configured, only listed IPs may access `/admin/*` | `["203.0.113.10"]` |
| `DISABLE_ADMIN_PASSWORD_CHECK` | Text/JSON | Warning: Admin console without password or user check | `false` |
When `ADMIN_API_IP_WHITELIST` is unset or empty, source IPs are not restricted. Once configured, it applies to both admin-password and Admin user-token access, trusts only Cloudflare's `CF-Connecting-IP` header, and denies requests without that header.
## Email Related Variables
| Variable Name | Type | Description | Example |