feat(secrets-mcp): 共享 key 删除时自动迁移并重定向 (v0.3.7)
All checks were successful
Secrets MCP — Build & Release / 检查 / 构建 / 发版 (push) Successful in 4m4s
Secrets MCP — Build & Release / 部署 secrets-mcp (push) Successful in 6s

删除仍被 metadata.key_ref 引用的 key 条目时,在同一事务内将密文复制到首个引用方,
其余引用方的 key_ref 重定向到新 owner;env_map 解析 key_ref 时不再限定 type=key。
Web 删除 API 返回 migrated;Dashboard 删除成功后提示迁移。

Bump secrets-mcp to 0.3.7;补充删除迁移相关单测(需 SECRETS_DATABASE_URL)。

Made-with: Cursor
This commit is contained in:
2026-04-03 09:27:20 +08:00
parent c3c536200e
commit df701f21b9
8 changed files with 487 additions and 29 deletions

View File

@@ -1,6 +1,6 @@
[package]
name = "secrets-mcp"
version = "0.3.6"
version = "0.3.7"
edition.workspace = true
[[bin]]

View File

@@ -990,11 +990,14 @@ async fn api_entry_delete(
.await
.ok_or((StatusCode::UNAUTHORIZED, Json(json!({ "error": "未登录" }))))?;
delete_by_id(&state.pool, entry_id, user_id)
let result = delete_by_id(&state.pool, entry_id, user_id)
.await
.map_err(map_entry_mutation_err)?;
Ok(Json(json!({ "ok": true })))
Ok(Json(json!({
"ok": true,
"migrated": result.migrated,
})))
}
// ── OAuth / Well-known ────────────────────────────────────────────────────────

View File

@@ -367,7 +367,7 @@
var nameEl = tr.querySelector('.cell-name');
var name = nameEl ? nameEl.textContent.trim() : '';
if (!id) return;
if (!confirm('确定删除条目「' + name + '」?关联的密文字段将一并删除。')) return;
if (!confirm('确定删除条目「' + name + '」?')) return;
fetch('/api/entries/' + encodeURIComponent(id), { method: 'DELETE', credentials: 'same-origin' })
.then(function (r) {
return r.json().then(function (data) {
@@ -375,7 +375,12 @@
return data;
});
})
.then(function () { window.location.reload(); })
.then(function (data) {
if (data && Array.isArray(data.migrated) && data.migrated.length > 0) {
alert('已自动迁移共享 key 引用:' + data.migrated.length + ' 个条目完成重定向。');
}
window.location.reload();
})
.catch(function (e) { alert(e.message || String(e)); });
});
});