GCP 端点与身份平台集成

GCP endpoint integration with identity platform

不胜感激。我对 GCP 有点陌生。我想保护 Cloud Run,这将是 运行 一些 API。我正在考虑使用 Identity Platform 创建一组使用 OAuth2 调用 API 的用户。

创建的 Cloud Run 服务受到 public 访问的限制。还有 API 当前 public 仅可用的端点和 returns 来自安全 Cloud Run 服务的响应。还创建了带有测试用户的 Identity Platform,我可以从 https://identitytoolkit.googleapis.com/v1.

中获取 SecureToken

API endpoint 配置文件如下:

  swagger: '2.0'
  host: *HOST*
  schemes:
    - https
  produces:
    - application/json
  x-google-backend:
    address: *https://HOST*
    protocol: h2
  paths:
    /hello:
      get:
        operationId: hello
        responses:
          '200':
            description: A successful response
            schema:
              type: string
        security:  #I presume I need to add security here
          - auth0_jwt: []
   #and here
   securityDefinitions:
     auth0_jwt:
       authorizationUrl: "" #???
       flow: "implicit"
       type: "oauth2"
       x-google-issuer: "https://securetoken.google.com/"  #???
       x-google-jwks_uri: ""   #???
       x-google-audiences: ""  #???

如何将安全身份验证从 Identity Platform 添加到 API Endpoint? 我的印象是我需要用安全部分更新配置,但不确定要使用什么值。或者这不是应该的方式?

https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=[KEY] 发出 post 请求,user:psw:returnSecureToken returns 给我一个令牌。

我只需要用正确的 security definitions.

更新 API 网关配置 yaml
securityDefinitions:
    auth0_jwt:
        authorizationUrl: ""
        flow: "implicit"
        type: "oauth2"
        x-google-issuer: "https://securetoken.google.com/{google-project-ID}"
        x-google-jwks_uri: "https://www.googleapis.com/service_accounts/v1/metadata/x509/securetoken@system.gserviceaccount.com"
        x-google-audiences: "{google-project-ID}"