【问题标题】:Is it possible for a trusted web activity to have a configurable start url?受信任的网络活动是否有可能具有可配置的起始 URL?
【发布时间】:2021-10-11 22:20:22
【问题描述】:

我的网络应用程序不在万维网上。相反,可以部署到多个客户的私有环境。我的客户想要一个包装此 Web 应用程序的 Android 应用程序。在我看来,Trusted Web Activity 是一条合适的路径。

但是,有一个症结所在。在integration guide 之后,在我看来,受信任的 Web 活动打开的 url 需要在 Android 清单中声明。这种方法需要为每个客户构建不同的应用程序,因为每个客户的部署都有不同的 url。是否可以设置受信任的 Web 活动,可以在设置或托管配置中选择启动 URL?

【问题讨论】:

  • 是来源不同还是需要同一个来源的不同网址?

标签: android android-manifest trusted-web-activity


【解决方案1】:

您应该可以为此使用multi-origin trusted web activity

您应用中的asset_statements 声明最终会如下所示:

<string name="asset_statements">
[{
    \"relation\": [\"delegate_permission/common.handle_all_urls\"],
    \"target\": {
        \"namespace\": \"web\",
        \"site\": \"https://app.customer1.example\"
    }
}],
[{
    \"relation\": [\"delegate_permission/common.handle_all_urls\"],
    \"target\": {
        \"namespace\": \"web\",
        \"site\": \"https://app.customer2.example\"
    }
}],
[{
    \"relation\": [\"delegate_permission/common.handle_all_urls\"],
    \"target\": {
        \"namespace\": \"web\",
        \"site\": \"https://app.customer3.example\"
    }
}],
...
</string>

您仍然需要在每次客户加入时更新您的应用,但没有办法解决这个问题 - 它被称为“受信任”列表是有原因的。

还要考虑此设置的安全后果 - 它可能允许从一个客户端站点到另一个客户端站点的一些跨域恶作剧,因此请确保您了解攻击面并能够将应用程序完全锁定到单个客户端站点。

【讨论】:

  • 是的,这真的不能很好地扩展。或许这毕竟不是正确的解决方案。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-22
  • 2013-03-23
  • 2019-03-31
  • 2019-09-18
  • 2012-02-21
  • 1970-01-01
相关资源
最近更新 更多