fix(kb): 不再按控制台传输形态拦截 API Key

- 删除 KBBindingSnapshot 的 secret_entry_allowed 能力位与服务端 catalog/save 的 KB 传输门禁
- 非 HTTPS 控制台保留明文传输提示,但不再阻断 Key 录入
- 保留 QA AI 严格 HTTPS/回环校验、管理员认证、写意图头与 Key 不回显
- 补齐明文 HTTP 页面与服务端写入回归测试,同步运行手册和 CHANGELOG
This commit is contained in:
Zhero & Miku
2026-11-25 10:47:53 +08:00
committed by 姚章浩
parent 7926c8e8b9
commit 32c7074f41
14 changed files with 131 additions and 322 deletions
-11
View File
@@ -37,9 +37,6 @@ func (config Config) handleKBBindings(w http.ResponseWriter, r *http.Request) {
writeJSON(w, http.StatusOK, map[string]any{"data": map[string]any{
"environments": views,
"storage_ready": storageReady,
// The page cannot test the server's transport rule from the browser URL
// alone (a TLS proxy and an untrusted proxy look identical there).
"secret_entry_allowed": consoleSecretEntryAllowed(r, config.QAAITrustTLSProxy, config.WeKnoraAllowPrivateHTTP),
}})
}
@@ -62,10 +59,6 @@ func (config Config) handleKBBindingCatalog(w http.ResponseWriter, r *http.Reque
writeJSON(w, http.StatusBadRequest, map[string]string{"error": "invalid knowledge base catalog request"})
return
}
if input.APIKey != "" && !secretTransportAllowedForPrivateConsole(r, config.QAAITrustTLSProxy, config.WeKnoraAllowPrivateHTTP) {
writeJSON(w, http.StatusBadRequest, map[string]string{"error": "密钥仅可通过有效HTTPS或本机回环地址录入;未保存、未发送密钥"})
return
}
catalog, err := config.KBBindings.Catalog(r.Context(), env, input)
if err != nil {
writeKBBindingError(w, err)
@@ -93,10 +86,6 @@ func (config Config) handleKBBindingSave(w http.ResponseWriter, r *http.Request)
writeJSON(w, http.StatusBadRequest, map[string]string{"error": "invalid knowledge base binding request"})
return
}
if input.APIKey != "" && !secretTransportAllowedForPrivateConsole(r, config.QAAITrustTLSProxy, config.WeKnoraAllowPrivateHTTP) {
writeJSON(w, http.StatusBadRequest, map[string]string{"error": "密钥仅可通过有效HTTPS或本机回环地址录入;未保存、未发送密钥"})
return
}
view, err := config.KBBindings.Save(r.Context(), env, input, actorFor(r), config.Now().UTC())
if err != nil {
writeKBBindingError(w, err)