feat(command): 添加动态配置、黑白名单与后台管理界面

- 新增 SQLite 数据库层(db.py)持久化命令监听配置,支持热更新无需重启
- 命令过滤从白名单扩展为黑白名单双模式(COMMAND_LIST_MODE: allow/deny)
- 新增后台管理页面 /admin/,侧边栏布局,支持在线修改所有命令监听配置
- 新增 REST API:GET/PUT /api/settings、POST /api/settings/reload
- 新增 rebuild_pattern() 支持配置变更后正则动态重编译
- 中间件放行 /admin 和 /api 路径免鉴权
- 添加 aiosqlite 依赖
This commit is contained in:
2026-05-03 15:22:53 +08:00
parent ed6e27f162
commit 9ffe78a9c2
8 changed files with 1194 additions and 14 deletions

View File

@@ -10,9 +10,9 @@ from .response import error
@web.middleware
async def auth_middleware(request: web.Request, handler):
""" /upload 和 /webhook 路径强制校验 API Key"""
# 健康检查不需要鉴权
if request.path == "/healthz":
"""需要鉴权的路径校验 API Key。/healthz 和 /admin/ 及 /api/ 开头的路径不需要鉴权"""
# 不需要鉴权的路径
if request.path == "/healthz" or request.path.startswith("/admin") or request.path.startswith("/api/"):
return await handler(request)
auth_header = request.headers.get("Authorization", "")