feat: add backdoor login functionality for testing environment
- Implemented SysUserMapper to include a method for selecting available users for backdoor login. - Created XML mappings for the new backdoor user selection query. - Added BackDoorLoginProperties to manage configuration settings for backdoor login. - Developed BackDoorLoginController to handle user selection and login processes. - Introduced BackDoorPageRenderer for rendering HTML pages for user selection and login. - Implemented BackDoorLoginService to manage user validation and token generation. - Added HTML templates for user selection, login, and error handling. - Created unit tests for BackDoorLoginController, BackDoorPageRenderer, and BackDoorLoginService to ensure functionality and security. - Documented usage and configuration in test-backdoor-login.md.
This commit is contained in:
@@ -144,3 +144,11 @@ lc_cms_auth:
|
||||
getUserInfoUrl: http://218.31.252.15:9081/prod-api/system/app/authorize/user/info
|
||||
resrtPwdUrl: http://218.31.252.15:9081/prod-api/ps/user/resetPwd/zkr
|
||||
changeStatusUrl: http://218.31.252.15:9081/prod-api/ps/user/change/status/zkr
|
||||
|
||||
# 测试环境无法连接统一门户时,允许从 PC 用户列表直接建立本系统登录态。
|
||||
backdoor:
|
||||
login:
|
||||
enabled: true
|
||||
max-users: 100
|
||||
portal-base-path: /shihezi
|
||||
api-base-path: /api/shihezi
|
||||
|
||||
@@ -60,6 +60,14 @@ token:
|
||||
# 令牌有效期(默认30分钟)
|
||||
expireTime: 30
|
||||
|
||||
# 测试用户后门登录。默认关闭,只允许在明确的测试 profile 中覆盖开启。
|
||||
backdoor:
|
||||
login:
|
||||
enabled: false
|
||||
max-users: 100
|
||||
portal-base-path: /shihezi
|
||||
api-base-path: /api/shihezi
|
||||
|
||||
# PageHelper分页插件
|
||||
pagehelper:
|
||||
helperDialect: oracle
|
||||
|
||||
36
ruoyi-admin/src/main/resources/backdoor/error.html
Normal file
36
ruoyi-admin/src/main/resources/backdoor/error.html
Normal file
@@ -0,0 +1,36 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<meta name="robots" content="noindex,nofollow,noarchive">
|
||||
<link rel="icon" href="data:,">
|
||||
<title>无法登录</title>
|
||||
<style>
|
||||
* { box-sizing: border-box; }
|
||||
body {
|
||||
display: grid;
|
||||
min-height: 100vh;
|
||||
margin: 0;
|
||||
place-items: center;
|
||||
padding: 20px;
|
||||
color: #1f2937;
|
||||
background: #f6f8fb;
|
||||
font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
|
||||
}
|
||||
main { width: min(440px, 100%); padding: 38px; border-radius: 16px; background: #fff; box-shadow: 0 18px 45px rgba(31, 41, 55, .09); text-align: center; }
|
||||
.icon { width: 48px; height: 48px; margin: 0 auto 18px; border-radius: 50%; color: #b42318; background: #fee4e2; font-size: 28px; font-weight: 700; line-height: 48px; }
|
||||
h1 { margin: 0; color: #111827; font-size: 22px; }
|
||||
p { margin: 12px 0 24px; color: #667085; }
|
||||
a { display: inline-block; padding: 9px 17px; border-radius: 8px; color: #fff; background: #1677ff; text-decoration: none; font-weight: 600; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<div class="icon">!</div>
|
||||
<h1>无法完成登录</h1>
|
||||
<p>@@MESSAGE@@</p>
|
||||
<a href="?">返回用户列表</a>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
107
ruoyi-admin/src/main/resources/backdoor/login.html
Normal file
107
ruoyi-admin/src/main/resources/backdoor/login.html
Normal file
@@ -0,0 +1,107 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<meta name="robots" content="noindex,nofollow,noarchive">
|
||||
<link rel="icon" href="data:,">
|
||||
<title>正在登录</title>
|
||||
<style>
|
||||
* { box-sizing: border-box; }
|
||||
body {
|
||||
display: grid;
|
||||
min-height: 100vh;
|
||||
margin: 0;
|
||||
place-items: center;
|
||||
padding: 20px;
|
||||
color: #1f2937;
|
||||
background: linear-gradient(145deg, #eef4ff, #f7f9fc 55%, #eef7f4);
|
||||
font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
|
||||
}
|
||||
.card {
|
||||
width: min(460px, 100%);
|
||||
padding: 44px 38px 36px;
|
||||
border: 1px solid rgba(15, 23, 42, .08);
|
||||
border-radius: 18px;
|
||||
background: #fff;
|
||||
box-shadow: 0 22px 55px rgba(31, 41, 55, .10);
|
||||
text-align: center;
|
||||
}
|
||||
.spinner {
|
||||
width: 46px;
|
||||
height: 46px;
|
||||
margin: 0 auto 24px;
|
||||
border: 4px solid #dce9f8;
|
||||
border-top-color: #1677ff;
|
||||
border-radius: 50%;
|
||||
animation: spin .8s linear infinite;
|
||||
}
|
||||
@keyframes spin { to { transform: rotate(360deg); } }
|
||||
h1 { margin: 0; color: #111827; font-size: 22px; }
|
||||
p { margin: 10px 0 0; color: #667085; }
|
||||
.user { color: #1677ff; font-weight: 600; }
|
||||
.error { display: none; margin-top: 18px; color: #b42318; }
|
||||
.actions { display: none; margin-top: 22px; gap: 10px; justify-content: center; flex-wrap: wrap; }
|
||||
.actions a { padding: 8px 13px; border-radius: 7px; color: #fff; background: #1677ff; text-decoration: none; }
|
||||
.actions a.secondary { color: #344054; background: #eef2f6; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main class="card">
|
||||
<div class="spinner" id="spinner" aria-hidden="true"></div>
|
||||
<h1>正在进入系统</h1>
|
||||
<p>正在以 <span class="user">@@USER_NAME@@</span> 的身份建立登录状态…</p>
|
||||
<p class="error" id="error">登录状态已建立,但自动跳转失败,请手动选择入口。</p>
|
||||
<div class="actions" id="actions">
|
||||
<a id="portalLink" href="#">进入求职门户</a>
|
||||
<a id="managementLink" class="secondary" href="#">进入管理端</a>
|
||||
<a class="secondary" href="?">返回用户列表</a>
|
||||
</div>
|
||||
</main>
|
||||
<script>
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
const token = @@TOKEN_JSON@@;
|
||||
const expireAt = @@EXPIRE_AT@@;
|
||||
const apiBase = @@API_BASE_PATH_JSON@@;
|
||||
const portalBase = @@PORTAL_BASE_PATH_JSON@@;
|
||||
const portalUrl = portalBase + '/job-portal';
|
||||
const managementUrl = portalBase + '/management/management/list/index?type=1';
|
||||
|
||||
['userInfo', 'getInfoCache', 'appUserId', 'resume_userId'].forEach(function (key) {
|
||||
localStorage.removeItem(key);
|
||||
sessionStorage.removeItem(key);
|
||||
});
|
||||
sessionStorage.removeItem('user');
|
||||
localStorage.setItem('access_token', token);
|
||||
localStorage.setItem('refresh_token', token);
|
||||
localStorage.setItem('expireTime', String(expireAt));
|
||||
localStorage.removeItem('lcToken');
|
||||
|
||||
document.getElementById('portalLink').href = portalUrl;
|
||||
document.getElementById('managementLink').href = managementUrl;
|
||||
|
||||
fetch(apiBase + '/getInfo', {
|
||||
method: 'GET',
|
||||
cache: 'no-store',
|
||||
credentials: 'same-origin',
|
||||
headers: { 'Authorization': 'Bearer ' + token }
|
||||
})
|
||||
.then(function (response) {
|
||||
if (!response.ok) throw new Error('HTTP ' + response.status);
|
||||
return response.json();
|
||||
})
|
||||
.then(function (result) {
|
||||
if (result.code !== 200) throw new Error('getInfo failed');
|
||||
window.location.replace(result.userType === 'common' ? portalUrl : managementUrl);
|
||||
})
|
||||
.catch(function () {
|
||||
document.getElementById('spinner').style.display = 'none';
|
||||
document.getElementById('error').style.display = 'block';
|
||||
document.getElementById('actions').style.display = 'flex';
|
||||
});
|
||||
}());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
136
ruoyi-admin/src/main/resources/backdoor/user-list.html
Normal file
136
ruoyi-admin/src/main/resources/backdoor/user-list.html
Normal file
@@ -0,0 +1,136 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<meta name="robots" content="noindex,nofollow,noarchive">
|
||||
<link rel="icon" href="data:,">
|
||||
<title>测试用户登录</title>
|
||||
<style>
|
||||
* { box-sizing: border-box; }
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
padding: 40px 20px;
|
||||
color: #1f2937;
|
||||
background: linear-gradient(145deg, #eef4ff 0%, #f7f9fc 48%, #eef7f4 100%);
|
||||
font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
|
||||
}
|
||||
.panel {
|
||||
width: min(1120px, 100%);
|
||||
margin: 0 auto;
|
||||
overflow: hidden;
|
||||
border: 1px solid rgba(15, 23, 42, .08);
|
||||
border-radius: 18px;
|
||||
background: rgba(255, 255, 255, .96);
|
||||
box-shadow: 0 22px 55px rgba(31, 41, 55, .10);
|
||||
}
|
||||
header { padding: 28px 30px 22px; border-bottom: 1px solid #edf0f5; }
|
||||
h1 { margin: 0; color: #111827; font-size: 24px; line-height: 1.35; }
|
||||
.subtitle { margin: 8px 0 0; color: #6b7280; }
|
||||
.warning {
|
||||
margin-top: 18px;
|
||||
padding: 10px 13px;
|
||||
border: 1px solid #f5d995;
|
||||
border-radius: 9px;
|
||||
color: #7c4a03;
|
||||
background: #fff9e8;
|
||||
}
|
||||
.toolbar {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 18px 30px;
|
||||
border-bottom: 1px solid #edf0f5;
|
||||
}
|
||||
form { display: flex; flex: 1; max-width: 620px; gap: 9px; }
|
||||
input {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
height: 40px;
|
||||
padding: 0 13px;
|
||||
border: 1px solid #cfd6e4;
|
||||
border-radius: 8px;
|
||||
outline: none;
|
||||
font: inherit;
|
||||
}
|
||||
input:focus { border-color: #3178c6; box-shadow: 0 0 0 3px rgba(49, 120, 198, .12); }
|
||||
button {
|
||||
height: 40px;
|
||||
padding: 0 20px;
|
||||
border: 0;
|
||||
border-radius: 8px;
|
||||
color: #fff;
|
||||
background: #2563a9;
|
||||
cursor: pointer;
|
||||
font-family: inherit;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
line-height: 40px;
|
||||
}
|
||||
.count { flex: none; color: #6b7280; }
|
||||
.table-wrap { overflow-x: auto; }
|
||||
table { width: 100%; border-collapse: collapse; }
|
||||
th, td { padding: 14px 16px; border-bottom: 1px solid #edf0f5; text-align: left; white-space: nowrap; }
|
||||
th { color: #667085; background: #fafbfc; font-size: 13px; font-weight: 600; }
|
||||
tbody tr:hover { background: #f8fbff; }
|
||||
td.id { color: #667085; font-variant-numeric: tabular-nums; }
|
||||
td.action { text-align: right; }
|
||||
td.action a {
|
||||
display: inline-block;
|
||||
padding: 7px 13px;
|
||||
border-radius: 7px;
|
||||
color: #fff;
|
||||
background: #1677ff;
|
||||
text-decoration: none;
|
||||
font-weight: 600;
|
||||
}
|
||||
td.action a:hover { background: #0958d9; }
|
||||
.kind { color: #344054; }
|
||||
small { color: #98a2b3; }
|
||||
.empty { height: 150px; color: #98a2b3; text-align: center; }
|
||||
footer { padding: 16px 30px 20px; color: #98a2b3; font-size: 12px; }
|
||||
@media (max-width: 700px) {
|
||||
body { padding: 14px 10px; }
|
||||
header, .toolbar { padding-left: 18px; padding-right: 18px; }
|
||||
.toolbar { align-items: stretch; flex-direction: column; }
|
||||
form { max-width: none; }
|
||||
.count { align-self: flex-end; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main class="panel">
|
||||
<header>
|
||||
<h1>选择一个 PC 用户登录</h1>
|
||||
<p class="subtitle">点击用户后将跳过外部单点登录,并以该用户身份进入石河子智慧就业服务系统。</p>
|
||||
<div class="warning">仅限测试环境使用。登录行为会写入审计记录,请勿在生产环境开启此入口。</div>
|
||||
</header>
|
||||
<section class="toolbar">
|
||||
<form method="get">
|
||||
<input name="keyword" value="@@KEYWORD@@" maxlength="50" autocomplete="off"
|
||||
placeholder="输入用户 ID、账号、姓名或手机号搜索">
|
||||
<button type="submit">搜索用户</button>
|
||||
</form>
|
||||
<div class="count">当前 @@COUNT@@ 条,最多显示 @@MAX_USERS@@ 条</div>
|
||||
</section>
|
||||
<div class="table-wrap">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>用户 ID</th>
|
||||
<th>账号</th>
|
||||
<th>姓名</th>
|
||||
<th>手机号</th>
|
||||
<th>用户来源 / 部门</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>@@ROWS@@</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<footer>如列表中没有目标账号,请使用上方搜索框;停用和已删除账号不会显示。</footer>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user