数据加密和完整性校验
This commit is contained in:
parent
dd0e2f4721
commit
20797914db
|
|
@ -62,8 +62,7 @@ export default {
|
|||
return {
|
||||
uploadUrl: process.env.VUE_APP_BASE_API + "/file/upload", // 上传的图片服务器地址
|
||||
headers: {
|
||||
Authorization: "Bearer " + getToken(),
|
||||
checkIntegrity:false, encryptRequest: false
|
||||
Authorization: "Bearer " + getToken()
|
||||
},
|
||||
Quill: null,
|
||||
currentValue: "",
|
||||
|
|
|
|||
|
|
@ -74,8 +74,7 @@ export default {
|
|||
uploadList: [],
|
||||
uploadFileUrl: process.env.VUE_APP_BASE_API + "/file/upload", // 上传文件服务器地址
|
||||
headers: {
|
||||
Authorization: "Bearer " + getToken(),
|
||||
checkIntegrity:false, encryptRequest: false
|
||||
Authorization: "Bearer " + getToken()
|
||||
},
|
||||
fileList: [],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -78,8 +78,7 @@ export default {
|
|||
hideUpload: false,
|
||||
uploadImgUrl: process.env.VUE_APP_BASE_API + "/file/upload", // 上传的图片服务器地址
|
||||
headers: {
|
||||
Authorization: "Bearer " + getToken(),
|
||||
checkIntegrity:false, encryptRequest: false
|
||||
Authorization: "Bearer " + getToken()
|
||||
},
|
||||
fileList: []
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,13 +9,7 @@
|
|||
<template v-if="device!=='mobile'">
|
||||
<search id="header-search" class="right-menu-item" />
|
||||
|
||||
<el-tooltip content="源码地址" effect="dark" placement="bottom">
|
||||
<ruo-yi-git id="bonus-git" class="right-menu-item hover-effect" />
|
||||
</el-tooltip>
|
||||
|
||||
<el-tooltip content="文档地址" effect="dark" placement="bottom">
|
||||
<ruo-yi-doc id="bonus-doc" class="right-menu-item hover-effect" />
|
||||
</el-tooltip>
|
||||
|
||||
<screenfull id="screenfull" class="right-menu-item hover-effect" />
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ const REGISTER_CONFIG = {
|
|||
|
||||
// 配置设置
|
||||
const CONFIG = {
|
||||
STRENGTH:STRENGTH_LEVELS.STRONG,//密码强度配置
|
||||
STRENGTH: STRENGTH_LEVELS.STRONG,//密码强度配置
|
||||
IS_OPEN_REGISTER: REGISTER_CONFIG.PHONE_REGISTER || REGISTER_CONFIG.EMAIL_REGISTER, // 是否开启注册
|
||||
IS_CODE_LOGIN: LOGIN_CONFIG.CODE_EMAIL_LOGIN || LOGIN_CONFIG.CODE_PHONE_LOGIN, // 是否开启短信登录
|
||||
// 数据设置
|
||||
|
|
@ -64,7 +64,7 @@ function getCodePlaceholderText() {
|
|||
const loginOptions = []
|
||||
if (LOGIN_CONFIG.CODE_PHONE_LOGIN) loginOptions.push('手机号')
|
||||
if (LOGIN_CONFIG.CODE_EMAIL_LOGIN) loginOptions.push('邮箱')
|
||||
return loginOptions.length ? loginOptions.join('/') : '';
|
||||
return loginOptions.length ? loginOptions.join('/') : ''
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ service.interceptors.request.use(config => {
|
|||
// 处理 GET 请求
|
||||
if (config.method === 'get' && config.params) {
|
||||
let params = tansParams(config.params).slice(0, -1)
|
||||
console.log(params)
|
||||
// 数据完整性校验
|
||||
if (CONFIG.dataSettings.integrityCheck && checkIntegrity) {
|
||||
config.headers['Params-Hash'] = hashWithSM3AndSalt(params)
|
||||
|
|
@ -70,6 +69,8 @@ service.interceptors.request.use(config => {
|
|||
|
||||
if (!isRepeatSubmit && (config.method === 'post' || config.method === 'put')) {
|
||||
let data = typeof config.data === 'object' ? JSON.stringify(config.data) : config.data
|
||||
let contentType = config.headers['Content-Type']
|
||||
if (contentType.includes('application/json')) {
|
||||
// 数据完整性校验
|
||||
if (CONFIG.dataSettings.integrityCheck && checkIntegrity) {
|
||||
config.headers['Params-Hash'] = hashWithSM3AndSalt(data)
|
||||
|
|
@ -79,6 +80,7 @@ service.interceptors.request.use(config => {
|
|||
if (CONFIG.dataSettings.encryptRequest && encryptRequest) {
|
||||
config.data = encryptCBC(data)
|
||||
}
|
||||
}
|
||||
// 检查请求数据大小
|
||||
const requestSize = JSON.stringify({ url: config.url, data: data, time: Date.now() }).length
|
||||
const limitSize = 1000 * 1024 * 1024 // 限制存放数据 5MB
|
||||
|
|
@ -97,20 +99,17 @@ service.interceptors.request.use(config => {
|
|||
}
|
||||
cache.session.setJSON('sessionObj', requestObj)
|
||||
}
|
||||
|
||||
return config
|
||||
}, error => {
|
||||
console.error(error)
|
||||
return Promise.reject(error)
|
||||
})
|
||||
|
||||
// 响应拦截器
|
||||
// 响应拦截器
|
||||
service.interceptors.response.use(res => {
|
||||
if (res.headers.encryptresponse) {
|
||||
res.data = JSON.parse(decryptCBC(res.data))
|
||||
}
|
||||
console.log(res)
|
||||
// 未设置状态码则默认成功状态
|
||||
const code = res.data.code || 200
|
||||
// 获取错误信息
|
||||
|
|
@ -173,9 +172,9 @@ export function download(url, params, filename, config) {
|
|||
})
|
||||
return service.post(url, params, {
|
||||
transformRequest: [(params) => {
|
||||
return params
|
||||
return tansParams(params)
|
||||
}],
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded', encryptResponse: false},
|
||||
responseType: 'blob',
|
||||
...config
|
||||
}).then(async(data) => {
|
||||
|
|
|
|||
|
|
@ -506,7 +506,7 @@ export default {
|
|||
handleExport() {
|
||||
this.download('schedule/job/export', {
|
||||
...this.queryParams
|
||||
}, `job_${new Date().getTime()}.xlsx`,{ headers: { encryptResponse: false } })
|
||||
}, `job_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@ export default {
|
|||
handleExport() {
|
||||
this.download('schedule/job/log/export', {
|
||||
...this.queryParams
|
||||
}, `log_${new Date().getTime()}.xlsx`,{ headers: { encryptResponse: false } })
|
||||
}, `log_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -330,7 +330,7 @@ export default {
|
|||
handleExport() {
|
||||
this.download('system/config/export', {
|
||||
...this.queryParams
|
||||
}, `config_${new Date().getTime()}.xlsx`,{ headers: { encryptResponse: false } })
|
||||
}, `config_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
/** 刷新缓存按钮操作 */
|
||||
handleRefreshCache() {
|
||||
|
|
|
|||
|
|
@ -395,7 +395,7 @@ export default {
|
|||
handleExport() {
|
||||
this.download('system/dict/data/export', {
|
||||
...this.queryParams
|
||||
}, `data_${new Date().getTime()}.xlsx`,{ headers: { encryptResponse: false } })
|
||||
}, `data_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ export default {
|
|||
handleExport() {
|
||||
this.download('system/dict/type/export', {
|
||||
...this.queryParams
|
||||
}, `type_${new Date().getTime()}.xlsx`,{ headers: { encryptResponse: false } })
|
||||
}, `type_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
/** 刷新缓存按钮操作 */
|
||||
handleRefreshCache() {
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ export default {
|
|||
handleExport() {
|
||||
this.download('system/logininfor/export', {
|
||||
...this.queryParams
|
||||
}, `logininfor_${new Date().getTime()}.xlsx`, { headers: { encryptResponse: false } })
|
||||
}, `logininfor_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ export default {
|
|||
handleExport() {
|
||||
this.download('system/operlog/export', {
|
||||
...this.queryParams
|
||||
}, `operlog_${new Date().getTime()}.xlsx`,{ headers: { encryptResponse: false } })
|
||||
}, `operlog_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ export default {
|
|||
handleExport() {
|
||||
this.download('system/post/export', {
|
||||
...this.queryParams
|
||||
}, `post_${new Date().getTime()}.xlsx`,{ headers: { encryptResponse: false } })
|
||||
}, `post_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -625,7 +625,7 @@ export default {
|
|||
handleExport() {
|
||||
this.download('system/role/export', {
|
||||
...this.queryParams
|
||||
}, `role_${new Date().getTime()}.xlsx`, { headers: { encryptResponse: false } })
|
||||
}, `role_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -365,7 +365,7 @@ export default {
|
|||
// 是否更新已经存在的用户数据
|
||||
updateSupport: 0,
|
||||
// 设置上传的请求头部
|
||||
headers: { Authorization: 'Bearer ' + getToken(), checkIntegrity:false, encryptRequest: false },
|
||||
headers: { Authorization: 'Bearer ' + getToken() },
|
||||
// 上传的地址
|
||||
url: process.env.VUE_APP_BASE_API + '/system/user/importData'
|
||||
},
|
||||
|
|
@ -667,7 +667,7 @@ export default {
|
|||
handleExport() {
|
||||
this.download('system/user/export', {
|
||||
...this.queryParams
|
||||
}, `user_${new Date().getTime()}.xlsx`,{ headers: { encryptResponse: false } })
|
||||
}, `user_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
/** 导入按钮操作 */
|
||||
handleImport() {
|
||||
|
|
@ -676,7 +676,7 @@ export default {
|
|||
},
|
||||
/** 下载模板操作 */
|
||||
importTemplate() {
|
||||
this.download('system/user/importTemplate', {}, `user_template_${new Date().getTime()}.xlsx`, { headers: { encryptResponse: false } }).then(response => {
|
||||
this.download('system/user/importTemplate', {}, `user_template_${new Date().getTime()}.xlsx`).then(response => {
|
||||
})
|
||||
},
|
||||
// 文件上传中处理
|
||||
|
|
|
|||
Loading…
Reference in New Issue