【问题标题】:Understanding service account vs scopes for gcloud compute instances了解 gcloud 计算实例的服务帐户与范围
【发布时间】:2019-09-25 15:25:47
【问题描述】:

我创建了一个 gcloud 计算实例,我想在同一个项目中使用 storage.objects.getfirebasedatabase.instances.update 范围执行操作。

每个实例都是使用 Compute Engine 默认服务帐号 numbers-compute@developer.gserviceaccount.com 创建的,该帐号在项目中具有 Editor 角色。因此,我假设实例在使用初始化时将具有所需的权限

admin.initializeApp({
  credential: admin.credential.applicationDefault()
});

然而,请求一个 firestore 实例会导致错误 Request had insufficient authentication scopes

现在我注意到,如果我 gcloud compute instances describe my-instance 结果同时提到了电子邮件和 serviceAccounts 的范围:

"serviceAccounts": [
    {
      "email": "numbers-compute@developer.gserviceaccount.com",
      "scopes": [
        "https://www.googleapis.com/auth/devstorage.read_only",
        "https://www.googleapis.com/auth/logging.write",
        "https://www.googleapis.com/auth/monitoring.write",
        "https://www.googleapis.com/auth/pubsub",
        "https://www.googleapis.com/auth/service.management.readonly",
        "https://www.googleapis.com/auth/servicecontrol",
        "https://www.googleapis.com/auth/trace.append"
      ]
    }
  ]

服务帐户电子邮件和预定义范围之间的关系是什么?实例是否未应用服务帐户的所有范围?

即使我想调整我的范围,我也需要一些帮助来将storage.objects.getfirebasedatabase.instances.update iam 定义转换为https://www.googleapis.com/auth/scope 格式。 (https://www.googleapis.com/auth/firebasedatabase.instances.update 不存在)

【问题讨论】:

    标签: google-compute-engine google-api-nodejs-client


    【解决方案1】:

    Owner、Editor 和 Viewer 等角色就是我们所说的原始角色 [1],它们并不包含 GCP 中每个资源的权限。我建议创建具有所需权限的自定义角色或选择适当的预定义角色 [2]。

    [1]https://cloud.google.com/iam/docs/understanding-roles#primitive_roles

    [2]https://cloud.google.com/iam/docs/understanding-roles#firebase-roles

    【讨论】:

      猜你喜欢
      • 2019-03-18
      • 2018-11-16
      • 2014-07-04
      • 1970-01-01
      • 1970-01-01
      • 2020-08-05
      • 2020-07-18
      • 2014-04-18
      • 1970-01-01
      相关资源
      最近更新 更多