Browse Source

csp策略

MaiXinRong 11 months ago
parent
commit
8ee88d7937
4 changed files with 8 additions and 3 deletions
  1. 1 2
      app/middleware/http_header.js
  2. 1 1
      config/config.default.js
  3. 3 0
      config/config.local.js
  4. 3 0
      config/config.qa.js

+ 1 - 2
app/middleware/http_header.js

@@ -16,8 +16,7 @@ module.exports = options => {
         ctx.set('strict-transport-security', 'max-age=31536000; includeSubDomains; preload');
         //
         const csp = [
-            'default-src', `'self' 'unsafe-inline' https://*.smartcost.com.cn https://*.aliyuncs.com https://*.qq.com/ https://res.wx.qq.com/;`,
-            'img-src', `'self' data: blob: https://*.aliyuncs.com http://*.smartcost.com.cn;`,
+            'default-src', `'self' data: 'unsafe-inline' 'unsafe-eval' https://*.smartcost.com.cn https://*.aliyuncs.com https://*.qq.com/`,
         ];
         ctx.set('Content-Security-Policy', csp.join(' '));
         // IE8以上版本用户,在下载时,不显示打开选项

+ 1 - 1
config/config.default.js

@@ -65,7 +65,7 @@ module.exports = appInfo => {
     config.pageSize = 15;
 
     // 中间件
-    config.middleware = ['httpHeader', 'gzip', 'urlParse', 'sortFilter', 'autoLogger', 'autoFinishLogger'];
+    config.middleware = ['gzip', 'urlParse', 'sortFilter', 'autoLogger', 'autoFinishLogger'];
 
     // session配置
     config.session = {

+ 3 - 0
config/config.local.js

@@ -49,6 +49,9 @@ module.exports = appInfo => {
         key: '9b67989994f9def437ea68bb495f0162',
     };
 
+    // 中间件
+    config.middleware = ['httpHeader', 'gzip', 'urlParse', 'sortFilter', 'autoLogger', 'autoFinishLogger'];
+
     // 前端验证
     config.jsValidator = {
         client: {},

+ 3 - 0
config/config.qa.js

@@ -31,6 +31,9 @@ module.exports = appInfo => {
     // 表名前缀
     config.tablePrefix = 'zh_';
 
+    // 中间件
+    config.middleware = ['httpHeader', 'gzip', 'urlParse', 'sortFilter', 'autoLogger', 'autoFinishLogger'];
+
     // redis设置
     config.redis = {
         client: {