代表用户使用 Google Cloud KMS

Using Google Cloud KMS on behalf of user

我有一个与 Google KMS 交互的 CLI 工具。为了让它工作,我将用户凭据作为存储在磁盘上的 JSON 文件获取。现在一个新的需求出现了。我需要用这个 CLI 工具制作一个网络应用程序。 Web 应用程序将通过 Google Cloud IAP 受到保护。问题是,我如何 运行 代表经过身份验证的用户使用 CLI 工具?

你不知道。最好使用 service-account 并分配所需的角色。该服务帐户仍然可以 domain-wide 授权(能够模拟任何用户,这是已知的)。

运行 来自 web-application 的 CLI 工具也可能 could/should 被避免。最好将他的 CLI 工具转换为 Cloud Function,然后通过 HTTP 触发器从 web-application 中调用它(以便尽可能限制对服务帐户的访问)。

这可能也需要重新考虑,security-wise:

I fetch the user credentials as a JSON file which is stored on disk.

即使可能需要,service-account 也不需要。