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:
2026-09-23 15:19:54 +08:00
parent dd546fc07b
commit be1a2899ba
80 changed files with 9029 additions and 493 deletions
@@ -5,7 +5,7 @@
<h3>插件管理 <span class="badge">Plugins</span></h3>
<p>上传发布插件包 · 每插件保留最近 3 个版本,超出自动清理</p>
</div>
<el-button :loading="overviewBusy" :icon="Refresh" @click="refresh">刷新</el-button>
<el-button :loading="listBusy" :icon="Refresh" @click="refresh">刷新</el-button>
</div>
<div class="cp-card block cp-rise up-card">
@@ -38,8 +38,11 @@
</div>
<div class="cp-card block cp-rise list-card">
<div class="card-title">插件列表</div>
<el-table :data="plugins" size="small" :loading="overviewBusy" :row-key="r => r.id">
<div class="list-head">
<div class="card-title">插件列表</div>
<el-input v-model="kw" placeholder="搜索插件 ID / 名称" clearable :prefix-icon="Search" size="small" style="width: 230px" @keyup.enter="onSearch" @clear="onSearch" />
</div>
<el-table :data="plugins" size="small" :loading="listBusy" :row-key="r => r.id">
<el-table-column label="插件 ID" min-width="160">
<template #default="{ row }"><b class="cell-strong mono">{{ row.id }}</b></template>
</el-table-column>
@@ -70,6 +73,7 @@
</template>
</el-table-column>
</el-table>
<PagerBar :total="total" :page="page" :page-size="pageSize" @change="onPageChange" />
</div>
<!-- 编辑插件 -->
@@ -199,7 +203,7 @@
<div class="dt-sec">
<div class="ed-sec-title">授权账号</div>
<div class="tags" v-if="detail.accounts?.length">
<el-tag v-for="a in detail.accounts" :key="a" size="small" effect="plain" type="success" round class="mono">{{ a }}</el-tag>
<el-tag v-for="a in detail.accounts" :key="a.account" size="small" effect="plain" type="success" round class="mono">{{ a.nickname ? `${a.nickname} · ${a.account}` : a.account }}</el-tag>
</div>
<span v-else class="dim">未授权任何账号,执行端不可见</span>
</div>
@@ -213,15 +217,19 @@
</template>
<script setup>
import { computed, onMounted, reactive, ref } from 'vue'
import { onMounted, reactive, ref } from 'vue'
import { ElMessage as message, ElMessageBox as dialog } from 'element-plus'
import { Refresh, UploadFilled, FolderOpened, Edit, Delete, View, Box, Files, User, Clock } from '@element-plus/icons-vue'
import { overview, overviewBusy, loadOverview } from '../store'
import { adminUpload, adminPluginDelete, adminPluginPatch } from '../api'
import { Refresh, UploadFilled, FolderOpened, Edit, Delete, View, Box, Files, User, Clock, Search } from '@element-plus/icons-vue'
import { adminPlugins, adminUpload, adminPluginDelete, adminPluginPatch } from '../api'
import { fmtTime } from '../format'
import PagerBar from '../components/PagerBar.vue'
import { usePagedList } from '../composables/usePagedList'
const plugins = computed(() => overview.value?.plugins || [])
const kw = ref('')
const list = usePagedList((p, s) => adminPlugins(p, s, kw.value), { onError: e => message.error('读取失败:' + (e.message || e)) })
const { items: plugins, total, page, size: pageSize, busy: listBusy, load: refresh, onPageChange, reset } = list
const pid = ref(''); const pname = ref(''); const pver = ref(''); const pfile = ref(null)
function onSearch() { reset() }
const uploading = ref(false)
const upRef = ref()
@@ -286,9 +294,6 @@ async function saveEdit() {
finally { saving.value = false }
}
async function refresh() {
try { await loadOverview(true) } catch (e) { message.error('读取失败:' + (e.message || e)) }
}
async function upload() {
if (!pid.value || !pver.value || !pfile.value) { message.warning('请填写插件 ID / 版本并选择 ZIP 包'); return }
uploading.value = true
@@ -317,6 +322,8 @@ onMounted(refresh)
<style scoped>
.up-card, .list-card { padding: 20px 22px; }
.up-card .card-title { margin-bottom: 16px; }
.list-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.list-head .card-title { margin-bottom: 0; }
.up-form :deep(.el-form-item) { margin-bottom: 16px; }
.file-row { display: flex; align-items: center; gap: 10px; }
.hint { font-size: 12px; color: var(--cp-ink-3); margin-top: 2px; line-height: 1.7; }