升级ember应用程序时的安全问题

时间:2015-05-18 17:30:27

标签: ember.js ember-data ember-cli content-security-policy

我有一个ember / ember-cli应用程序,我正在从1.10升级到1.12。此应用程序使用在开发中在端口8000上运行的API。我有以下environment.js

module.exports = function(environment) {
  var ENV = {
    modulePrefix: 'myapplication',
    environment: environment,
    baseURL: '/',
    locationType: 'auto',
    EmberENV: {
      FEATURES: {
      }
    },
    contentSecurityPolicy: {
      'default-src': "'none'",
      'script-src': "'self'",
      'font-src': "'self'",
      'img-src': "'self'",
      'style-src': "'self'",
      'media-src': "'self'"
    },
    APP: {}
  };

  if (environment === 'development') {
    ENV.APP.API_NAMESPACE = '';
    ENV.APP.LOG_VIEW_LOOKUPS = true;
    ENV.contentSecurityPolicy['connect-src'] = "http://localhost:8000";
  }

  if (environment === 'test') {
    // [snipped]
  }

  if (environment === 'production') {
    // [snipped]
 }

  return ENV;
};

所以这之前有效,但是现在,当向API发出请求时,它正在进入端口4200,因此返回时没有找到。

crossdomain.xml具有以下内容:

<site-control permitted-cross-domain-policies="none"/>

但将其更改为"all"并没有帮助。顺便提一下,ember-cli-content-security-policy似乎已从0.3.0更新为0.4.0

修改 代理ember serve --proxy http://localhost:8000后,我收到以下错误:

Content Security Policy violation: 
{  
   "csp-report":{  
      "document-uri":"http://localhost:4200/",
      "referrer":"",
      "violated-directive":"connect-src http://localhost:8000 ws://localhost:35729 ws://0.0.0.0:35729 http://0.0.0.0:4200/csp-report",
      "effective-directive":"connect-src",
      "original-policy":"default-src 'none'; script-src 'self' localhost:35729 0.0.0.0:35729; font-src 'self'; img-src 'self'; style-src 'self'; media-src 'self'; connect-src http://localhost:8000 ws://localhost:35729 ws://0.0.0.0:35729 http://0.0.0.0:4200/csp-report; report-uri http://0.0.0.0:4200/csp-report;",
      "blocked-uri":"http://localhost:4200/myapp",
      "source-file":"http://localhost:4200/assets/vendor.js",
      "line-number":9827,
      "column-number":10,
      "status-code":200
   }
}

1 个答案:

答案 0 :(得分:2)

我相信你需要添加多个主机,一个用于端口:8000和端口:4200