mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-12-04 10:24:00 +00:00
fix: isolate server-side donation credentials and rotate auth defaults
This commit is contained in:
1 parent
3047ba97a2
commit
d57c708869
19 files changed
+190
-125
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nfd-web",
|
||||
"version": "0.4.14",
|
||||
"version": "0.4.15",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
<el-icon><Key /></el-icon>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="捐赠网盘账号" placement="bottom">
|
||||
<el-tooltip v-if="donatedAccountsEnabled" content="捐赠网盘账号" placement="bottom">
|
||||
<el-button circle size="small" type="warning" @click="showDonateDialog = true">
|
||||
<el-icon><Present /></el-icon>
|
||||
</el-button>
|
||||
@@ -319,6 +319,10 @@
|
||||
width="550px"
|
||||
:close-on-click-modal="false">
|
||||
<el-form :model="authConfig" label-width="100px" size="default">
|
||||
<el-form-item label="服务认证密钥">
|
||||
<el-input v-model="serverAuthKey" type="password" show-password
|
||||
autocomplete="off" placeholder="自建站已配置的 authEncryptKey(仅本页内存)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="网盘类型" required>
|
||||
<el-select v-model="authConfig.panType" placeholder="请选择网盘类型" style="width: 100%" @change="onPanTypeChange">
|
||||
<el-option-group label="必须认证">
|
||||
@@ -573,10 +577,6 @@
|
||||
<el-form :model="donateConfig" label-width="100px" size="default">
|
||||
<el-form-item label="网盘类型" required>
|
||||
<el-select v-model="donateConfig.panType" placeholder="请选择网盘类型" style="width: 100%" @change="onDonatePanTypeChange">
|
||||
<el-option-group label="必须认证">
|
||||
<el-option label="夸克网盘 (QK)" value="QK" />
|
||||
<el-option label="UC网盘 (UC)" value="UC" />
|
||||
</el-option-group>
|
||||
<el-option-group label="大文件需认证">
|
||||
<el-option label="小飞机网盘 (FJ)" value="FJ" />
|
||||
<el-option label="蓝奏优享 (IZ)" value="IZ" />
|
||||
@@ -712,8 +712,10 @@ export default {
|
||||
},
|
||||
// 所有网盘的认证配置 { panType: config }
|
||||
allAuthConfigs: {},
|
||||
serverAuthKey: '',
|
||||
|
||||
// 捐赠账号相关
|
||||
donatedAccountsEnabled: false,
|
||||
showDonateDialog: false,
|
||||
donateSubmitting: false,
|
||||
donateConfig: {
|
||||
@@ -979,6 +981,10 @@ export default {
|
||||
|
||||
// 保存认证配置
|
||||
saveAuthConfig() {
|
||||
if (![16, 24, 32].includes(new TextEncoder().encode(this.serverAuthKey).length)) {
|
||||
this.$message.warning('个人认证需要自建站配置的服务认证密钥(16、24 或 32 个 UTF-8 字节)')
|
||||
return
|
||||
}
|
||||
if (!this.authConfig.panType) {
|
||||
this.$message.warning('请先选择网盘类型')
|
||||
return
|
||||
@@ -1021,6 +1027,7 @@ export default {
|
||||
ext5: ''
|
||||
}
|
||||
this.allAuthConfigs = {}
|
||||
this.serverAuthKey = ''
|
||||
localStorage.removeItem('nfd_auth_configs')
|
||||
this.$message.success('所有认证配置已清除')
|
||||
this.showAuthConfigDialog = false
|
||||
@@ -1040,31 +1047,15 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
// 生成加密的 auth 参数(优先使用个人配置,否则从后端随机获取捐赠账号)
|
||||
// 个人认证由可信客户端使用自建服务显式配置的密钥编码;捐赠凭据只在服务端使用。
|
||||
async generateAuthParam() {
|
||||
const panType = this.getCurrentPanType()
|
||||
if (!panType) return ''
|
||||
|
||||
let config = null
|
||||
|
||||
// 优先使用个人配置
|
||||
if (this.allAuthConfigs[panType]) {
|
||||
config = this.allAuthConfigs[panType]
|
||||
} else {
|
||||
// 从后端随机获取捐赠账号(后端已加密,直接使用 encryptedAuth)
|
||||
try {
|
||||
const response = await axios.get(`${this.baseAPI}/v2/randomAuth`, { params: { panType } })
|
||||
const encryptedAuth = response.data?.data?.encryptedAuth
|
||||
if (encryptedAuth) {
|
||||
return encryptedAuth
|
||||
}
|
||||
} catch (e) {
|
||||
// no available donated account
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
// 个人配置:本地 AES 加密
|
||||
const config = this.allAuthConfigs[panType]
|
||||
if (!config) return ''
|
||||
const key = this.serverAuthKey
|
||||
if (![16, 24, 32].includes(new TextEncoder().encode(key).length)) return ''
|
||||
|
||||
const authObj = {}
|
||||
if (config.authType) authObj.authType = config.authType
|
||||
if (config.username) authObj.username = config.username
|
||||
@@ -1079,7 +1070,7 @@ export default {
|
||||
if (config.ext5) authObj.ext5 = config.ext5
|
||||
|
||||
try {
|
||||
const encrypted = this.aesEncrypt(JSON.stringify(authObj), 'nfd_auth_key2026')
|
||||
const encrypted = this.aesEncrypt(JSON.stringify(authObj), key)
|
||||
return encodeURIComponent(encrypted)
|
||||
} catch (e) {
|
||||
console.error('生成认证参数失败:', e)
|
||||
@@ -1719,7 +1710,11 @@ export default {
|
||||
token: isPasswordAuth ? '' : (this.donateConfig.token || ''),
|
||||
remark: this.donateConfig.remark || ''
|
||||
}
|
||||
await axios.post(`${this.baseAPI}/v2/donateAccount`, payload)
|
||||
const response = await axios.post(`${this.baseAPI}/v2/donateAccount`, payload)
|
||||
if (response.data?.code !== 200) {
|
||||
this.$message.error(response.data?.msg || '捐赠失败')
|
||||
return
|
||||
}
|
||||
this.$message.success(`已捐赠 ${this.getPanDisplayName(this.donateConfig.panType)} 账号,感谢您的贡献!`)
|
||||
|
||||
// 重置表单
|
||||
@@ -1749,6 +1744,7 @@ export default {
|
||||
}
|
||||
|
||||
if (data && typeof data === 'object') {
|
||||
this.donatedAccountsEnabled = data.enabled === true
|
||||
// 兼容新结构: { active: {...}, inactive: {...} }
|
||||
if (data.active && data.inactive) {
|
||||
if (data.active.total === undefined) {
|
||||
|
||||
Reference in new issue
Block a user