hmp 4 年之前
父節點
當前提交
ee68847a07
共有 2 個文件被更改,包括 26 次插入1 次删除
  1. 5 1
      assets/http/service.js
  2. 21 0
      utils/crypto.js

+ 5 - 1
assets/http/service.js

@@ -29,7 +29,11 @@ http.interceptors.request.use((config) => {
 		...config.header,
 		"Blade-Auth": getTokenStorage()
 	}
-	if (Global.enabledCrypto && config.method == 'POST' && config.data) {
+	// 1:开启加密
+	// 2:post请求
+	// 3:请求体不为空
+	// 4: url不在白名单内
+	if (Global.enabledCrypto && config.method == 'POST' && config.data && crypto.isNotInWhiteList(config.url)) {
 		//报文加密
 		let encrypt= crypto.encrypt(JSON.stringify(config.data))
 		config.data=encrypt

+ 21 - 0
utils/crypto.js

@@ -3,6 +3,27 @@ console.log(CryptoJS.HmacSHA1("Message", "Key"));
 
 let crypto = {}
 
+const WHITE_LIST = [
+	'/yeepay',
+	'/put-file',
+	'/blade-test',
+	'/payment',
+	'/sms',
+	'/mall/yeepay/product/fee/modifyProductFeeNotify',
+	'/shop/yeepay/product/fee/modifyProductFeeNotify',
+	'/withdraw',
+	'/pressure_test/scanPay',
+	'/pressure_test/deCodeNotifyData',
+	'/ocr',
+	'/import-bank-type'
+]
+
+crypto.isNotInWhiteList = (url) => {
+	return !WHITE_LIST.some(item => {
+		return url.indexOf(item) > 0
+	})
+}
+
 //前后端定义的密钥,AES使用16位
 const CRYPTOJS_KEY = "uAY9ugkHQpvozZeA";
 // 加密