【问题标题】:Use API Gateway with authentication from Cloud SQL将 API Gateway 与来自 Cloud SQL 的身份验证结合使用
【发布时间】:2021-09-17 04:36:37
【问题描述】:

我在 Cloud Run 上运行微服务,我想利用 API Gateway。

是否可以使用 API Gateway 通过 Cloud Run 中的 Cloud Function 或容器(从 Cloud SQL 中的数据库查询用户数据)对我的用户进行身份验证?

【问题讨论】:

    标签: google-cloud-functions cloud google-cloud-sql gateway


    【解决方案1】:

    TL;DR:你不能。

    使用 API 网关,built-in authentication method 的数量有限。简而言之,您拥有 API 密钥(不推荐,因为它是一个长期存在的令牌)和 OAuth2(具有 FirebaseAuth/Cloud Identity Platform、Okta、Auth0 或自定义 IdP 的 JWT 令牌)。

    在您的情况下,如果您想为自己的用户使用自己的数据库,则需要在 Cloud SQL 数据库前面插入 OAuth 身份提供程序并实现所需的业务逻辑。然后,将 API Gateway 与自定义 IDP 一起使用。

    但是,最简单的方法是使用 Firebase 或 Cloud Identity Platform(这是 GCP 中 FirebaseAuth 的实现)。用户不在您的数据库中,但您可以想象同步(API 调用)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-04
      • 1970-01-01
      • 2019-08-30
      • 2019-12-08
      • 1970-01-01
      • 2019-04-28
      • 2011-01-16
      • 1970-01-01
      相关资源
      最近更新 更多