feat: 完成 issue #134 登录认证+用户/角色管理(web/auth,RBAC 三级,OIDC 预留,接入配置台)

This commit is contained in:
2026-08-05 10:14:25 +08:00
parent faddf24d11
commit 7cf783e7c6
7 changed files with 548 additions and 0 deletions
+68
View File
@@ -0,0 +1,68 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>iAOP 登录</title>
<style>
/* iAOP 登录页(issue #134 / PRD 8.2):深色主题对齐驾驶舱 */
body { margin:0; font-family:"Microsoft YaHei",sans-serif; background:#0b1220;
color:#e6edf6; display:flex; align-items:center; justify-content:center;
min-height:100vh; }
.card { background:#13203a; border:1px solid rgba(255,255,255,.06); border-radius:10px;
padding:28px 32px; width:340px; }
h1 { font-size:18px; color:#18d3c8; margin:0 0 4px; }
.sub { font-size:12px; color:#8aa0bd; margin-bottom:18px; }
label { display:block; font-size:13px; margin:12px 0 4px; }
input { width:100%; padding:9px 10px; border-radius:6px; border:1px solid rgba(255,255,255,.12);
background:#0b1220; color:#e6edf6; box-sizing:border-box; }
button { width:100%; margin-top:18px; padding:10px; border:none; border-radius:6px;
background:#18d3c8; color:#04202a; font-size:14px; cursor:pointer; }
#sso-btn { background:#1e293b; color:#e6edf6; margin-top:10px; }
.err { color:#ff3b30; font-size:12px; margin-top:10px; min-height:16px; }
.hint { font-size:11px; color:#64748b; margin-top:14px; }
</style>
</head>
<body>
<div class="card">
<h1>iAOP 平台登录</h1>
<div class="sub">本地账号 / 企业 IAM(SSO) 双轨 · PRD 8.2</div>
<label>用户名</label>
<input id="username" autocomplete="username" placeholder="admin">
<label>密码</label>
<input id="password" type="password" autocomplete="current-password" placeholder="admin123(首次内置)">
<button id="login-btn">登录</button>
<button id="sso-btn" hidden>企业 SSO 登录(OIDC)</button>
<div class="err" id="err"></div>
<div class="hint">首次运行内置管理员 admin / admin123,登录后请在用户管理页修改密码。<br>
SSO 未配置时仅本地账号可用;配置 OIDC(issuer/client_id)后此处出现 SSO 入口。</div>
</div>
<script src="auth.js"></script>
<script>
// 已登录则直接回跳
var next = new URLSearchParams(location.search).get("next") || "../studio/index.html";
Auth._ensureSeed().then(function () {
if (Auth.session()) location.href = next;
// OIDC 配置点:已配置则显示 SSO 入口(PRD 8.2 双轨)
var url = Auth.oidcAuthorizeUrl();
if (url) {
var btn = document.getElementById("sso-btn");
btn.hidden = false;
btn.onclick = function () { location.href = url; };
}
});
function doLogin() {
var err = document.getElementById("err");
err.textContent = "";
Auth.login(document.getElementById("username").value.trim(),
document.getElementById("password").value)
.then(function () { location.href = next; })
.catch(function (e) { err.textContent = e.message; });
}
document.getElementById("login-btn").onclick = doLogin;
document.getElementById("password").addEventListener("keydown", function (e) {
if (e.key === "Enter") doLogin();
});
</script>
</body>
</html>