Подтвердить что ты не робот

Нарушение директивы политики безопасности контента после ember-cli 0.0.47 upgrade

Я обновил мое приложение ember-cli до 0.0.47 и теперь получаю кучу ошибок в моей консоли браузера, связанных с политикой безопасности контента. Как исправить эту проблему?

Refused to load the script 'http://use.typekit.net/abcdef.js' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval' localhost:35729".
 login:1
Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval' localhost:35729". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution.
 login:20
Refused to load the script 'http://connect.facebook.net/en_US/all.js' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval' localhost:35729".
 login:1
Refused to load the script 'http://maps.googleapis.com/maps/api/js?libraries=places' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval' localhost:35729".

Вот строки в файле app/index.html:

<script type="text/javascript" src="//use.typekit.net/abcdef.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places"></script>
4b9b3361

Ответ 1

После чтения некоторых документов в http://content-security-policy.com/ и https://github.com/rwjblue/ember-cli-content-security-policy я добавил некоторые политики для моего config/environment.js, например:

module.exports = function(environment) {
  var ENV = {
    contentSecurityPolicy: {
      'default-src': "'none'",
      'script-src': "'self' 'unsafe-inline' 'unsafe-eval' use.typekit.net connect.facebook.net maps.googleapis.com maps.gstatic.com",
      'font-src': "'self' data: use.typekit.net",
      'connect-src': "'self'",
      'img-src': "'self' www.facebook.com p.typekit.net",
      'style-src': "'self' 'unsafe-inline' use.typekit.net",
      'frame-src': "s-static.ak.facebook.com static.ak.facebook.com www.facebook.com"
    },

  // ...
};

Это заставило все немедленные ошибки уйти, но как только я начал навигацию к своему приложению, появились новые, связанные с источниками мультимедиа S3.

Я уверен, что это работает для приложений, которые не включают внешние ресурсы, но я решил удалить "ember-cli-content-security-policy" из моего файла package.json.

Ответ 2

Мне пришлось использовать это при ссылке на шрифты из google:

<link rel='stylesheet' href='http://fonts.googleapis.com/css?family=Lato:400,700,900'>

В файле config/environment.js я использовал

contentSecurityPolicy: {
  'font-src': "'self' data: fonts.gstatic.com",
  'style-src': "'self' 'unsafe-inline' fonts.googleapis.com"
},