merge: 合并 #150 认证后端/登录页,落地 #134 用户/角色管理+OIDC 预留+配置台接入

This commit is contained in:
2026-08-05 10:20:09 +08:00
16 changed files with 1263 additions and 418 deletions
+23 -21
View File
@@ -458,7 +458,7 @@ function publish() {
changelog: "发布模板资产包", snapshot: currentSnapshot()
});
store("studio.releases.v1", studioState.releases);
if (typeof Auth !== "undefined") Auth.audit("publish", "release", version); // #134 写操作审计
if (typeof UserStore !== "undefined") UserStore.audit("publish", "release", version); // #134 写操作审计
renderVersions();
}
@@ -481,7 +481,7 @@ function rollbackTo(index) {
changelog: "回滚自 " + target.version, snapshot: currentSnapshot()
});
store("studio.releases.v1", studioState.releases);
if (typeof Auth !== "undefined") Auth.audit("rollback", "release", "回滚自 " + target.version);
if (typeof UserStore !== "undefined") UserStore.audit("rollback", "release", "回滚自 " + target.version);
renderVersions(); renderCanvas(); renderHyperForm();
}
@@ -545,25 +545,27 @@ var studioState = {
function persistConfig() { store("studio.config.v1", studioState.config); }
(function init() {
// 认证门控(issue #134):从 web/ 根目录起服务时加载 ../auth/auth.js,
// 未登录跳登录页;登录后角色以会话为准(角色下拉锁定)。
// auth.js 缺失(独立起服务于 web/studio)时降级为手动角色切换演示。
if (typeof Auth !== "undefined") {
var session = Auth.requireAuth("../auth/login.html");
if (!session) return; // 正在跳转登录页
currentRole = session.role;
var roleSelect = document.getElementById("role-select");
roleSelect.value = session.role;
roleSelect.disabled = true;
document.getElementById("role-hint").textContent =
session.username + " · " + RBAC[currentRole].label +
(Auth.can(session.role, "manage") ? " · 用户管理 →" : "");
if (Auth.can(session.role, "manage")) {
document.getElementById("role-hint").style.cursor = "pointer";
document.getElementById("role-hint").onclick = function () {
location.href = "../auth/users.html";
};
}
// 认证门控(issue #134,会话 API 来自 #150 的 IAOP_AUTH):未登录跳登录页
// (后端 core/auth /auth/me 校验);登录后角色以会话为准(角色下拉锁定)。
// auth.js 缺失(独立起服务于 web/studio 的纯静态演示)时降级为手动角色切换。
if (typeof IAOP_AUTH !== "undefined") {
IAOP_AUTH.requireLoginElseRedirect("../auth/login.html").then(function (user) {
if (!user) return; // 正在跳转登录页
currentRole = user.role;
var roleSelect = document.getElementById("role-select");
roleSelect.value = user.role;
roleSelect.disabled = true;
document.getElementById("role-hint").textContent =
user.username + " · " + RBAC[currentRole].label +
(user.role === "admin" ? " · 用户管理 →" : "");
applyRbac(); renderHyperForm(); renderCanvas(); renderBindPanel(); renderVersions();
if (user.role === "admin") {
document.getElementById("role-hint").style.cursor = "pointer";
document.getElementById("role-hint").onclick = function () {
location.href = "../auth/users.html";
};
}
});
}
// 页签切换
document.querySelectorAll(".tab").forEach(function (tab) {