gpt4 book ai didi

google-cloud-platform - HTTP Google Cloud Functions 中的身份验证

转载 作者:行者123 更新时间:2023-12-04 02:16:30 25 4
gpt4 key购买 nike

https://cloud.google.com/solutions/authentication-in-http-cloud-functions

该文档建议设置一个 Google Cloud Storage 存储桶。然后为存储桶设置服务帐户的权限“storage.buckets.get”。

然后使用此权限验证对 http Google Cloud Functions 的访问。

我们正在谈论对 http 云功能进行身份验证,但我们正在借用 Google Cloud Storage 的许可。在我看来,这是一个黑客解决方案。

如果我们可以通过 Google Cloud Console 在每个云功能上设置权限,那就太好了。

你们是否使用上述文档中 Google 建议的身份验证解决方案?或者你有更好的方法?

要设置“storage.buckets.get”,是否意味着我授予服务帐户“Storage Object Viewer”权限?

enter image description here

最佳答案

link中提出的解决方案你带来这里确实是其中一种方式。事实上,您可以使用任何其他 Google Cloud Platform 产品(不仅是 Storage 存储分区)来检查所选帐户对其的权限。

一个可行的替代方案是:

  • 准备一个云功能,其中将列出授权用户的电子邮件。
  • Cloud Function 检索 'Authorization'传入 HTTP 请求的 header ,其中包含为发出请求的帐户生成的 token 。
  • 该函数调用 tokeninfo endpoint使用提到的 header 检索帐户的电子邮件(来自 JSON 响应正文)。返回电子邮件的 url 将如下所示:

  • url = "https://www.googleapis.com/oauth2/v1/tokeninfo?fields=email&access_token
    =" + token_from_the_request_header;
  • 验证返回的电子邮件是否在授权列表中。
  • ...如果是,则执行函数的逻辑。
  • 关于google-cloud-platform - HTTP Google Cloud Functions 中的身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48531608/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com