🔒️ security(server): 业务接口保护开关与存活探针
- access_key 改用 subtle.ConstantTimeCompare 常量时间比较,防时序攻击 - 新增 server.protect_all 配置:开启后业务接口(/search、/content 等)也要求访问密钥 - 代理路由(/audio/proxy/、/manga/image/)不参与保护,其 URL 由服务端生成不含 key - 新增 /healthz 存活探针(不校验密钥,供容器/反代使用) - openapi.yaml 补 /healthz 定义,Unauthorized 描述说明 protect_all 行为 - 新增 3 个测试:保护开关放行、healthz、错误响应行为
This commit is contained in:
1 parent
d1774a3902
commit
24c7e4b6fd
5 files changed
+78
-26
No files matched your search
+15
-1
@@ -50,6 +50,20 @@ paths:
|
||||
message: { type: string, example: success }
|
||||
data: { nullable: true }
|
||||
|
||||
/healthz:
|
||||
get:
|
||||
tags: [系统]
|
||||
summary: 存活探针
|
||||
description: 供容器/反向代理探活,不校验访问密钥。
|
||||
operationId: getHealthz
|
||||
responses:
|
||||
"200":
|
||||
description: 服务存活
|
||||
content:
|
||||
text/plain:
|
||||
schema: { type: string }
|
||||
example: ok
|
||||
|
||||
/status:
|
||||
get:
|
||||
tags: [系统]
|
||||
@@ -750,7 +764,7 @@ components:
|
||||
|
||||
responses:
|
||||
Unauthorized:
|
||||
description: 访问密钥缺失或无效
|
||||
description: 访问密钥缺失或无效(业务接口仅在 server.protect_all 开启时需要)
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
|
||||
Reference in new issue
Block a user