【问题标题】:Meteor - Cordova - Allow images from third party services and block other urlsMeteor - Cordova - 允许来自第三方服务的图像并阻止其他 url
【发布时间】:2019-06-17 20:15:46
【问题描述】:

我正在尝试创建一个访问规则,该规则只允许以图像扩展名结尾的链接。我试过使用这条规则但没有成功:

App.accessRule('https://*.jpg', {type: 'intent'});

我们的想法是包含所有可能的图像扩展名,但不允许任何其他链接。

此外,最好不要拒绝以查询字符串结尾的链接,例如

[url].jpg?witdh=540&heigth=300

这可能实现吗?

【问题讨论】:

  • I've tried using this rule without success 这个“没有成功”是什么样子的?有什么错误吗?也许您的网络服务器/代理端存在 https 与 http 问题?

标签: cordova meteor


【解决方案1】:

注意: App.accessRule 只能用于添加规则。因此,请确保现有规则尚未匹配。 (https://docs.meteor.com/api/mobile-config.html#App-accessRule)

注意 2: 白名单仅适用于 Cordova 主 Web 视图,不适用于 InAppBrowser Web 视图或系统 Web 浏览器中的打开链接。 (https://cordova.apache.org/docs/en/6.x/guide/appdev/whitelist/index.html#ios-whitelisting)

注意 3:我们建议您使用更安全的内容安全策略(见下文)。对于不支持 CSP 的 webview,此白名单主要是历史性的。 (https://cordova.apache.org/docs/en/6.x/reference/cordova-plugin-whitelist/#network-request-whitelist)

所以我的建议是使用 CSP,例如允许来自 https 和 self 的所有图像:

Content-Security-Policy: img-src https: 'self';

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/img-src

【讨论】:

    猜你喜欢
    • 2021-05-23
    • 2013-07-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多