Skip to content

fix: /health 端点免鉴权,避免代理探活因 secret 不一致误判为不健康#13

Open
estelledc wants to merge 1 commit into
SuperJJ007:mainfrom
estelledc:fix/issue-12-health-no-auth
Open

fix: /health 端点免鉴权,避免代理探活因 secret 不一致误判为不健康#13
estelledc wants to merge 1 commit into
SuperJJ007:mainfrom
estelledc:fix/issue-12-health-no-auth

Conversation

@estelledc

Copy link
Copy Markdown

解决的问题

Closes #12

问题描述

/health 端点要求 path-secret 鉴权。当 config.secret 被清空或轮换后,所有现有的监控探活(Rust 侧 status() 命令、面板状态灯)全部返回 403 → 误判代理不健康 → 状态灯黄灯。实际上代理正在正常运行,只是 secret 不一致。

修改

  • /health 改为免鉴权。健康检查仅返回 {"status":"ok","provider":"deepseek"},不含密钥、令牌或任何敏感信息,加鉴权反而引入脆弱性
  • 同时匹配裸路径 /health 和带 secret 前缀的路径 /<secret>/health,兼容新旧调用方
  • 测试更新:test_health_without_secret_forbiddentest_health_without_secret_ok,期望值从 403 改为 200

验证

# 全量测试通过
bash test/run_all.sh
# ALL GREEN

影响范围

  • 向后兼容:带 secret 前缀的 /health 请求仍正常返回 200
  • 安全面无退化:/health 不含敏感数据,/v1/messages/v1/models 仍受 secret 保护
  • Rust 侧 proc::http_health() 无需修改(仍可带或不带 secret 调用)

问题:/health 端点要求 path-secret 鉴权。当 config.secret 被清空/轮换后,
现有的监控探活全部 403 → 误判代理不健康 → 状态灯黄灯。

修改:
- /health 改为免鉴权(健康检查不含敏感信息,加鉴权反而引入脆弱性)
- 同时匹配裸路径和带 secret 前缀的路径,兼容新旧调用方
- 测试从 assert 403 改为 assert 200

Closes SuperJJ007#12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 代理进程挂掉后无恢复/无提示,Science 报 403 错误信息误导

1 participant