本次提交包含多项安全加固和体验优化: 1. 分离管理密钥与传输凭证,避免持 API Token 者伪造管理员票据 2. 钉钉回调地址增加白名单校验,防止开放重定向钓鱼 3. 初始管理员密码改为随机生成并日志记录,移除硬编码 123456 4. 新增登录防爆破计数表,支持 MySQL 多 worker 共享 5. 统一分页规范,新增 usePagedList composable 和 PagerBar 组件 6. 控制面 CORS 收敛为白名单,避免公网环境下任意站点跨域 7. 插件管理、凭证管理等列表接口支持分页和搜索 8. 强制初始密码修改,未改密前禁止使用管理功能 9. 定时任务触发被拒日志节流,避免授权失效时刷屏 10. 健康检查接口移除环境信息泄露,返回固定响应
116 lines
4.8 KiB
Vue
116 lines
4.8 KiB
Vue
<template>
|
||
<div class="page">
|
||
<div class="page-head cp-rise">
|
||
<div>
|
||
<h3>敏感凭证 <span class="badge">Creds</span></h3>
|
||
<p>执行机敏感凭证的明文源(钉钉开放平台)。保存后客户端下次启动用 RSA 私钥解密拉取;留空 = 该键不下发</p>
|
||
</div>
|
||
<el-button :loading="busy" :icon="Refresh" @click="refresh">刷新</el-button>
|
||
</div>
|
||
|
||
<div class="cp-card panel cp-rise">
|
||
<el-table :data="rows" v-loading="busy" size="default" style="width: 100%">
|
||
<el-table-column prop="account" label="执行机账号" width="180">
|
||
<template #default="{ row }">
|
||
<span class="mono">{{ row.nickname ? `${row.nickname} · ${row.account}` : row.account }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="公钥" width="90">
|
||
<template #default="{ row }">
|
||
<el-tag :type="row.has_pubkey ? 'success' : 'info'" size="small" effect="light">
|
||
{{ row.has_pubkey ? '已上报' : '未上报' }}
|
||
</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column v-for="k in keyCols" :key="k.key" :label="k.label" min-width="170" show-overflow-tooltip>
|
||
<template #default="{ row }">
|
||
<span class="mono dim" :class="{ empty: !row.creds[k.key] }">{{ row.creds[k.key] || '(未配置)' }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column prop="updated_at" label="更新时间" width="170" />
|
||
<el-table-column label="操作" width="90" fixed="right">
|
||
<template #default="{ row }">
|
||
<el-button link type="primary" :icon="EditPen" @click="openEdit(row)">编辑</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
<template #empty>
|
||
<el-empty description="暂无账号,客户端启动注册后自动出现" :image-size="80" />
|
||
</template>
|
||
</el-table>
|
||
<PagerBar :total="total" :page="page" :page-size="pageSize" @change="onPageChange" />
|
||
</div>
|
||
|
||
<el-dialog v-model="dlg" :title="`编辑凭证 · ${editing?.account || ''}`" width="540px">
|
||
<div class="form">
|
||
<div class="fitem" v-for="k in keyCols" :key="k.key">
|
||
<label>{{ k.label }} <span class="dim mono">({{ k.key }})</span></label>
|
||
<el-input v-model="form[k.key]" :type="k.key.includes('SECRET') ? 'password' : 'text'"
|
||
:show-password="k.key.includes('SECRET')" placeholder="留空 = 不下发该键" />
|
||
</div>
|
||
<p class="tip">值仅管理台可见;保存后客户端下次启动拉取更新(离线用本地加密缓存)。</p>
|
||
</div>
|
||
<template #footer>
|
||
<el-button @click="dlg = false">取消</el-button>
|
||
<el-button type="primary" :loading="saving" @click="save">保存</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { onMounted, ref } from 'vue'
|
||
import { Refresh, EditPen } from '@element-plus/icons-vue'
|
||
import { ElMessage as message } from 'element-plus'
|
||
import { adminCredsList, adminCredsSeed } from '../api'
|
||
import PagerBar from '../components/PagerBar.vue'
|
||
import { usePagedList } from '../composables/usePagedList'
|
||
|
||
const KEY_COLS = [
|
||
{ key: 'DINGTALK_APPKEY', label: 'AppKey' },
|
||
{ key: 'DINGTALK_APPSECRET', label: 'AppSecret' },
|
||
{ key: 'DINGTALK_AGENT_ID', label: 'AgentId' },
|
||
{ key: 'DINGTALK_CORP_ID', label: 'CorpId' },
|
||
]
|
||
|
||
const keyCols = KEY_COLS
|
||
const list = usePagedList((p, s) => adminCredsList(p, s), { onError: e => message.error('读取失败:' + (e.message || e)) })
|
||
const { items: rows, total, page, size: pageSize, busy, load: refresh, onPageChange } = list
|
||
const dlg = ref(false)
|
||
const saving = ref(false)
|
||
const editing = ref(null)
|
||
const form = ref({})
|
||
|
||
function openEdit(row) {
|
||
editing.value = row
|
||
form.value = {}
|
||
keyCols.forEach(c => { form.value[c.key] = row.creds?.[c.key] || '' })
|
||
dlg.value = true
|
||
}
|
||
|
||
async function save() {
|
||
if (!editing.value) return
|
||
saving.value = true
|
||
try {
|
||
const values = {}
|
||
keyCols.forEach(c => { if (form.value[c.key]) values[c.key] = String(form.value[c.key]).trim() })
|
||
const r = await adminCredsSeed({ account: editing.value.account, values })
|
||
message.success(`已保存 ${r.seeded_keys.length} 个键(留空键已清除)`)
|
||
dlg.value = false
|
||
await refresh()
|
||
} catch (e) { message.error('保存失败:' + (e.message || e)) }
|
||
finally { saving.value = false }
|
||
}
|
||
|
||
onMounted(refresh)
|
||
</script>
|
||
|
||
<style scoped>
|
||
.panel { padding: 22px 24px 26px; }
|
||
.form { display: flex; flex-direction: column; gap: 16px; }
|
||
.fitem { display: flex; flex-direction: column; gap: 7px; }
|
||
.fitem label { font-size: 13px; font-weight: 700; color: var(--cp-ink-1); }
|
||
.fitem .dim { font-weight: 500; font-size: 12px; }
|
||
.empty { color: var(--cp-ink-3); }
|
||
.tip { font-size: 12px; color: var(--cp-ink-3); margin: 2px 0 0; }
|
||
</style>
|