feat: 重构控制面安全机制与分页规范
本次提交包含多项安全加固和体验优化: 1. 分离管理密钥与传输凭证,避免持 API Token 者伪造管理员票据 2. 钉钉回调地址增加白名单校验,防止开放重定向钓鱼 3. 初始管理员密码改为随机生成并日志记录,移除硬编码 123456 4. 新增登录防爆破计数表,支持 MySQL 多 worker 共享 5. 统一分页规范,新增 usePagedList composable 和 PagerBar 组件 6. 控制面 CORS 收敛为白名单,避免公网环境下任意站点跨域 7. 插件管理、凭证管理等列表接口支持分页和搜索 8. 强制初始密码修改,未改密前禁止使用管理功能 9. 定时任务触发被拒日志节流,避免授权失效时刷屏 10. 健康检查接口移除环境信息泄露,返回固定响应
This commit is contained in:
@@ -6,11 +6,17 @@
|
||||
<p>建号 · 部门 / 管理员维护 · 密码重置(不能操作自己的账号)</p>
|
||||
</div>
|
||||
<div class="head-acts">
|
||||
<el-button :loading="overviewBusy" :icon="Refresh" @click="refresh">刷新</el-button>
|
||||
<el-button :loading="busy" :icon="Refresh" @click="refresh">刷新</el-button>
|
||||
<el-button type="primary" :icon="Plus" @click="openCreate">新建账号</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 账号搜索(服务端模糊:账号/昵称/部门) -->
|
||||
<div class="search-bar cp-card cp-rise">
|
||||
<el-input v-model="kw" placeholder="搜索账号 / 昵称 / 部门" clearable :prefix-icon="Search" style="width: 300px" @keyup.enter="onSearch" @clear="onSearch" />
|
||||
<span v-if="kw" class="dim-sm">搜索中:{{ kw }}</span>
|
||||
</div>
|
||||
|
||||
<!-- 账号卡片 -->
|
||||
<div class="acct-grid" v-if="accounts.length">
|
||||
<div class="acct-card cp-card cp-rise" v-for="(a, i) in accounts" :key="a.account" :style="{ animationDelay: i * 40 + 'ms' }">
|
||||
@@ -46,8 +52,8 @@
|
||||
|
||||
<div class="acct-tags" v-if="a.plugins?.length">
|
||||
<span class="tag-label">插件</span>
|
||||
<el-tag v-for="p in a.plugins.slice(0, 3)" :key="p" size="small" type="primary" effect="light" round class="mono">{{ p }}</el-tag>
|
||||
<span v-if="a.plugins.length > 3" class="more mono">+{{ a.plugins.length - 3 }}</span>
|
||||
<el-tag v-for="p in a.plugins.slice(0, 2)" :key="p" size="small" type="primary" effect="light" round class="mono">{{ p }}</el-tag>
|
||||
<span v-if="a.plugins.length > 2" class="more mono">+{{ a.plugins.length - 2 }}</span>
|
||||
</div>
|
||||
<div class="acct-tags" v-else>
|
||||
<span class="tag-label">插件</span>
|
||||
@@ -65,7 +71,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<el-empty v-else-if="!overviewBusy" description="暂无账号,点击右上角「新建账号」" :image-size="90" class="cp-card" />
|
||||
<el-empty v-else-if="!busy" description="暂无账号,点击右上角「新建账号」" :image-size="90" class="cp-card" />
|
||||
<PagerBar v-if="total > 0" :total="total" :page="page" :page-size="pageSize" @change="onPageChange" />
|
||||
|
||||
<!-- 新建账号 -->
|
||||
<el-dialog v-model="createOpen" title="新建账号" width="440px" align-center destroy-on-close @closed="resetCreate">
|
||||
@@ -77,7 +84,7 @@
|
||||
<el-input v-model="form.nickname" placeholder="真实姓名,方便识别(可填钉钉名)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="初始密码" prop="password">
|
||||
<el-input v-model="form.password" type="password" placeholder="至少 6 位" show-password />
|
||||
<el-input v-model="form.password" type="password" placeholder="至少 8 位" show-password />
|
||||
</el-form-item>
|
||||
<el-form-item label="部门">
|
||||
<el-input v-model="form.dept" placeholder="如 财务部 / IT" />
|
||||
@@ -121,9 +128,9 @@
|
||||
<!-- 重置密码 -->
|
||||
<el-dialog v-model="resetOpen" title="重置密码" width="420px" align-center destroy-on-close>
|
||||
<el-alert type="info" :closable="false" class="reset-tip" show-icon>
|
||||
为账号 <b class="mono">{{ resetTarget }}</b> 设置新密码(至少 6 位)
|
||||
为账号 <b class="mono">{{ resetTarget }}</b> 设置新密码(至少 8 位)
|
||||
</el-alert>
|
||||
<el-input v-model="resetPwdVal" type="password" placeholder="新密码(至少 6 位)" show-password @keyup.enter="confirmReset" />
|
||||
<el-input v-model="resetPwdVal" type="password" placeholder="新密码(至少 8 位)" show-password @keyup.enter="confirmReset" />
|
||||
<template #footer>
|
||||
<div class="modal-foot">
|
||||
<el-button @click="resetOpen = false">取消</el-button>
|
||||
@@ -137,18 +144,19 @@
|
||||
<script setup>
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage as message, ElMessageBox as dialog } from 'element-plus'
|
||||
import { Refresh, Plus, Camera, EditPen, Edit, Delete } from '@element-plus/icons-vue'
|
||||
import { store, overview, overviewBusy, loadOverview } from '../store'
|
||||
import { adminAccountCreate, adminAccountUpdate, adminAccountReset, adminAccountDelete, adminAvatarUpload } from '../api'
|
||||
import { Refresh, Plus, Camera, EditPen, Edit, Delete, Search } from '@element-plus/icons-vue'
|
||||
import { store } from '../store'
|
||||
import { adminAccounts, adminAccountCreate, adminAccountUpdate, adminAccountReset, adminAccountDelete, adminAvatarUpload } from '../api'
|
||||
import { fmtTime } from '../format'
|
||||
import PagerBar from '../components/PagerBar.vue'
|
||||
import { usePagedList } from '../composables/usePagedList'
|
||||
|
||||
const current = computed(() => store.current || '')
|
||||
const accounts = computed(() => overview.value?.accounts || [])
|
||||
const kw = ref('')
|
||||
const list = usePagedList((p, s) => adminAccounts(p, s, kw.value), { onError: e => message.error('读取失败:' + (e.message || e)) })
|
||||
const { items: accounts, total, page, size: pageSize, busy, load: refresh, onPageChange, reset } = list
|
||||
const busySwitch = ref('')
|
||||
|
||||
async function refresh() {
|
||||
try { await loadOverview(true) } catch (e) { message.error('读取失败:' + (e.message || e)) }
|
||||
}
|
||||
function onSearch() { reset() }
|
||||
|
||||
// ---------- 头像(显示 + 上传) ----------
|
||||
const _fileInput = (() => {
|
||||
@@ -188,7 +196,7 @@ const rules = {
|
||||
account: { required: true, message: '请输入账号' },
|
||||
password: [
|
||||
{ required: true, message: '请输入初始密码' },
|
||||
{ min: 6, message: '密码至少 6 位' },
|
||||
{ min: 8, message: '密码至少 8 位' },
|
||||
],
|
||||
}
|
||||
function openCreate() { createOpen.value = true }
|
||||
@@ -244,7 +252,7 @@ function resetPwd(a) {
|
||||
}
|
||||
async function confirmReset() {
|
||||
const p = resetPwdVal.value
|
||||
if (p.length < 6) { message.warning('密码至少 6 位'); return }
|
||||
if (p.length < 8) { message.warning('密码至少 8 位'); return }
|
||||
resetting.value = true
|
||||
try {
|
||||
await adminAccountReset({ account: resetTarget.value, new_password: p })
|
||||
@@ -271,6 +279,7 @@ onMounted(refresh)
|
||||
<style scoped>
|
||||
.head-acts { display: flex; gap: 10px; }
|
||||
|
||||
.search-bar { display: flex; align-items: center; gap: 12px; padding: 14px 18px; margin-bottom: 16px; }
|
||||
.acct-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
|
||||
|
||||
Reference in New Issue
Block a user