mirror of
https://gitcode.com/JianFeeeee/ModelRouter.git
synced 2026-09-27 12:53:05 +00:00
feat(deploy): 部署前校验 master.key 可解封配置 + llmsproxy -show-secrets
密钥校验(deploy.sh) - 新增 verify_master_key,在 build/替换任何文件之前执行。失败则二进制与 配置分毫未动、服务不受影响(已负向验证:缺钥匙、错钥匙两种情况都挡住) - 走真实的 -show-secrets 解密路径,而不是只检查钥匙文件格式——格式合法 但内容不匹配(重新生成、恢复了错的备份、换机器)同样会被拒 - 钥匙来源与 config 包一致:LLMS_PROXY_MASTER_KEY 优先,否则 dirname(runtime_file)/master.key - 配置里没有密文时跳过并提示(首次加密场景) -show-secrets - llmsproxy -show-secrets -config <path>:把凭据打到 stdout 后退出 - 不启动任何东西、不写任何文件(已验证 mtime 不变) - 加密往返无损:封存前后输出逐字节一致 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@ -24,6 +24,7 @@ import (
|
||||
func main() {
|
||||
cfgPath := flag.String("config", "config.yaml", "path to gateway config file")
|
||||
checkOnly := flag.Bool("check", false, "validate the config file and exit (0 = valid, 1 = invalid); nothing is started and no file is written")
|
||||
showSecrets := flag.Bool("show-secrets", false, "print the config's credentials in the clear and exit; nothing is started and no file is written")
|
||||
flag.Parse()
|
||||
|
||||
// -check is the deploy-time preflight: parse and validate the config
|
||||
@ -41,6 +42,20 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
// -show-secrets is the operator escape hatch for a config whose
|
||||
// credentials are sealed at rest: it prints them to stdout and exits
|
||||
// without starting anything or writing anything. Nothing else in the
|
||||
// program prints a credential, and this path never logs to a file.
|
||||
if *showSecrets {
|
||||
if _, err := os.Stat(*cfgPath); err != nil {
|
||||
log.Fatalf("[llmsproxy] show-secrets: %v", err)
|
||||
}
|
||||
if err := config.PrintSecrets(*cfgPath); err != nil {
|
||||
log.Fatalf("[llmsproxy] show-secrets: %v", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
created, err := config.EnsureDefault(*cfgPath)
|
||||
if err != nil {
|
||||
log.Fatalf("[llmsproxy] config: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user