mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-21 02:25:56 +08:00
修改接口参数是否加密, 默认为不加密.
This commit is contained in:
parent
5ae176305e
commit
76c196dbec
@ -199,7 +199,7 @@ mybatis-encryptor:
|
||||
# 数据加密
|
||||
request-encryptor:
|
||||
# 是否开启加密
|
||||
enable: true
|
||||
enable: false
|
||||
# AES 加密头标识
|
||||
headerFlag: AES
|
||||
# 公私钥 非对称算法的公私钥 如:SM2,RSA
|
||||
|
||||
@ -11,7 +11,7 @@ VITE_APP_BASE_API = '/dev-api'
|
||||
VITE_APP_CONTEXT_PATH = '/'
|
||||
|
||||
# 请求接口是否加密
|
||||
IS_ENCRYPT = 'true'
|
||||
VITE_APP_IS_ENCRYPT = false
|
||||
|
||||
# 监控地址
|
||||
VITE_APP_MONITRO_ADMIN = 'http://localhost:9090/admin/applications'
|
||||
|
||||
@ -8,7 +8,7 @@ VITE_APP_ENV = 'production'
|
||||
VITE_APP_CONTEXT_PATH = '/'
|
||||
|
||||
# 请求接口是否加密
|
||||
IS_ENCRYPT = 'true'
|
||||
VITE_APP_IS_ENCRYPT = false
|
||||
|
||||
# 监控地址
|
||||
VITE_APP_MONITRO_ADMIN = '/admin/applications'
|
||||
|
||||
@ -31,8 +31,6 @@ service.interceptors.request.use(config => {
|
||||
const isToken = (config.headers || {}).isToken === false
|
||||
// 是否需要防止数据重复提交
|
||||
const isRepeatSubmit = (config.headers || {}).repeatSubmit === false
|
||||
// 是否需要加密
|
||||
const isEncrypt = (config.headers || {}).isEncrypt === import.meta.env.IS_ENCRYPT
|
||||
if (getToken() && !isToken) {
|
||||
config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
||||
}
|
||||
@ -67,7 +65,7 @@ service.interceptors.request.use(config => {
|
||||
}
|
||||
}
|
||||
// 当开启参数加密
|
||||
if (isEncrypt && (config.method === 'post' || config.method === 'put')) {
|
||||
if (import.meta.env.VITE_APP_IS_ENCRYPT === 'true' && (config.method === 'post' || config.method === 'put')) {
|
||||
// 生成一个 AES 密钥
|
||||
const aesKey = generateAesKey();
|
||||
config.headers['AES'] = encrypt(aesKey.toString(CryptoJS.enc.Base64));
|
||||
|
||||
@ -8,7 +8,7 @@ ENV = 'development'
|
||||
VUE_APP_BASE_API = '/dev-api'
|
||||
|
||||
# 请求接口是否加密
|
||||
IS_ENCRYPT = 'true'
|
||||
VUE_APP_IS_ENCRYPT = false
|
||||
|
||||
# 应用访问路径 例如使用前缀 /admin/
|
||||
VUE_APP_CONTEXT_PATH = '/'
|
||||
|
||||
@ -8,7 +8,7 @@ ENV = 'production'
|
||||
VUE_APP_BASE_API = '/prod-api'
|
||||
|
||||
# 请求接口是否加密
|
||||
IS_ENCRYPT = 'true'
|
||||
VUE_APP_IS_ENCRYPT = false
|
||||
|
||||
# 应用访问路径 例如使用前缀 /admin/
|
||||
VUE_APP_CONTEXT_PATH = '/'
|
||||
|
||||
@ -34,8 +34,7 @@ service.interceptors.request.use(config => {
|
||||
if (getToken() && !isToken) {
|
||||
config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
||||
}
|
||||
// 是否需要加密
|
||||
const isEncrypt = (config.headers || {}).isEncrypt === process.env.IS_ENCRYPT
|
||||
|
||||
// get请求映射params参数
|
||||
if (config.method === 'get' && config.params) {
|
||||
let url = config.url + '?' + tansParams(config.params);
|
||||
@ -67,7 +66,7 @@ service.interceptors.request.use(config => {
|
||||
}
|
||||
}
|
||||
// 当开启参数加密
|
||||
if (isEncrypt && (config.method === 'post' || config.method === 'put')) {
|
||||
if (process.env.VUE_APP_IS_ENCRYPT === 'true' && (config.method === 'post' || config.method === 'put')) {
|
||||
// 生成一个 AES 密钥
|
||||
const aesKey = generateAesKey();
|
||||
config.headers['AES'] = encrypt(aesKey.toString(CryptoJS.enc.Base64));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user