【问题标题】:Google Cloud Resource Manager API - grant owner role to a userGoogle Cloud Resource Manager API - 向用户授予所有者角色
【发布时间】:2016-05-19 20:07:11
【问题描述】:

我在 Google Apps 脚本中使用具有服务帐户授权的 Google Cloud Resource Manager API。在程序中,我有兴趣更新开发者控制台项目的角色。

具体来说,我正在尝试将开发者控制台项目的所有者更改为编辑器,并将另一个用户更改为所有者。这一点,我相信就 HTTP 请求负载而言,它看起来像:

// before (taken from response of getIamPolicy REST call)
{
    "bindings": [{
            "role": "roles/owner",
            "members": ["user:abc@my-google-domain.com"]
     }],
    "version": "0",
    "etag": "acbqwcada="
}

// after (modified policy) used in setIamPolicy REST call
{
    "bindings": [{
            "role": "roles/owner",
            "members": ["user:def@my-google-domain.com"]
     },
     {
            "role": "roles/editor",
            "members": ["user:abc@my-google-domain.com"]
     }],
    "version": "0",
    "etag": "acbqwcada="
}

我观察到的几件事:

  • 将当前 owner(用户电子邮件)更改为 editor 并添加 新所有者(用户电子邮件)时,API 调用正在返回SOLO_MUST_INVITE_OWNERS 错误。在这里,我将服务帐户模拟为项目的初始所有者,具有所有必要的域范围访问权限

  • 但是,当我在 Google API Explorer 中使用相同的有效负载执行相同的调用时,它工作正常!

  • Google Cloud 和 Identity Management 文档似乎令人困惑。它说在某一点"Cloud Resource Manager IAM methods only support granting the owner role to user and serviceAccount" 而在另一点"A user cannot be granted owner access using setIamPolicy(). The user must be granted the owner role using the Cloud Platform Console and he must explicitly accept the invitation." -- 我想知道除了 setIamPolicy() 之外还有其他方法来设置策略吗?

【问题讨论】:

    标签: google-api google-apps google-cloud-platform


    【解决方案1】:

    云资源管理器 API 不支持通过setIamPolicysee the documentation on setIamPolicy 添加所有者:

    要添加为所有者,必须通过云平台邀请用户 控制台并且必须接受邀请。

    在您邀请 def@my-google-domain.com 并且他们已接受之后(他们将在 Cloud Platform 控制台中显示为项目的所有者,同时也是 getIamPolicy 返回的 owner 绑定的成员)您可以拨打setIamPolicy 拨打abc@my-google-domain.comeditor

    【讨论】:

    • doc 中提到“Cloud Resource Manager IAM 方法仅支持将所有者角色授予用户和 serviceAccount。”
    • 只有用户或服务帐户才能成为项目的所有者(意味着只有 "user:foo@...""serviceAccount:bar@..."owner 绑定中支持的成员),但 CRM API 目前不支持使用 @ 987654334@ 让他们成为所有者。目前,唯一的方法是通过 Cloud Platform 控制台。
    猜你喜欢
    • 2019-05-21
    • 2020-04-27
    • 2017-02-09
    • 1970-01-01
    • 2019-04-13
    • 2020-12-30
    • 1970-01-01
    • 2020-11-30
    • 1970-01-01
    相关资源
    最近更新 更多