阻止googleapis脚本加载的内容安全策略

时间:2015-11-27 15:15:04

标签: android cordova google-maps-api-3

我为我的Android应用尝试了各种不同的内容安全策略,但我总是收到错误:

Refused to load the script 'http://192.168.1.254/oie/mobile-step0.html?originalurl=maps.googleapis.com' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-inline' 'unsafe-eval'
                           127.0.0.1:*
                           http://*.itunes.apple.com
                           http://*.googleapis.com
                           http://*.maxplatform.com
                           https://*.itunes.apple.com
                           https://*.googleapis.com
                           https://*.maxplatform.com
                           ".

我的安全政策的完整内容是:

   <meta http-equiv="Content-Security-Policy"
          content="default-src *;
               script-src 'self' 'unsafe-inline' 'unsafe-eval'
                           127.0.0.1:*
                           http://*.itunes.apple.com
                           http://*.googleapis.com
                           http://*.maxplatform.com
                           https://*.itunes.apple.com
                           https://*.googleapis.com
                           https://*.maxplatform.com
                           ;
               style-src  'self' 'unsafe-inline'
                           127.0.0.1:*
                           http://*.itunes.apple.com
                           http://*.googleapis.com
                           http://*.maxplatform.com
                           https://*.itunes.apple.com
                           https://*.googleapis.com
                           https://*.maxplatform.com
    ">

我在config.xml中使用了cordova白名单插件,其中包含以下设置:

    <allow-navigation href="*" />
    <allow-intent href="*" />
    <access origin="*" />

google maps api的脚本标记是:

<script src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>

我在三星Android 4.2手机上运行。

如果我将http://192.168.1.254添加到内容安全策略中,它可以正常工作,但我肯定不需要它,无论如何它是特定于我的设置,只适用于通过我的本地网络调试我的Android应用程序。

我需要找到一个解决方案,即内容安全策略,在没有添加192.168.1.254的情况下工作。

0 个答案:

没有答案
相关问题