API网关直通连接

发布于 2025-01-22 06:17:34 字数 750 浏览 4 评论 0原文

我们有多个API,每个API都有许多端点,这些API受OAuth的保护,因此需要一个令牌才能访问任何API。

我们最终将把这些大的API分解为微服务穿过令牌,使API可以对其进行处理。

我之前已经提到过“直接连接”,但我无法找到有关此的任何真实信息,因此实际上可能是不可能的。

我还知道,这种违背了OpenAPI规格应该使用的内容,但理想情况下是我们目前想要的:

paths:
 /myapi/*:
    get:
      security:
      - Bearer: []
      summary: Pass calls to my-api
      operationId: get
      x-google-backend:
        address: https://my-api-12345.run.app/    
      responses:
        '200':
          description: OK

我可以称呼https://gw-adsgae.gateway.dev。 /myapi/infohttps://gw-adsgae.gateway.dev/myapi/customer,并且它将通过网关将载体令牌传递到云运行中的API实例无需实际指定网关的OpenAPI规范中的所有单个端点和单独的路径,以匹配网关后面API中的所有端点,

这是完全可能的吗?

有没有办法将令牌穿过网关,而无需网关试图使用令牌做任何事情?

We have multiple APIs with many endpoints in each one and these APIs are protected using oAuth so a token is required to access any of the APIs.

We will eventually break these large APIs into microservices but for now I need to try and add a Cloud Run instance to a GCP API Gateway that will basically just proxy any request through the gateway to the API backend allowing the API to function "normally" including passing through the token so that the API can process that itself.

I have heard a "straight through connection" mentioned before but I've not been able to find any real information about this so it may not actually be possible.

I also get that this kind of goes against what the OpenAPI spec is supposed to be used for but ideally something like the following is what we currently want:

paths:
 /myapi/*:
    get:
      security:
      - Bearer: []
      summary: Pass calls to my-api
      operationId: get
      x-google-backend:
        address: https://my-api-12345.run.app/    
      responses:
        '200':
          description: OK

so that I could call https://gw-adsgae.gateway.dev/myapi/info or https://gw-adsgae.gateway.dev/myapi/customer and that it would go through the gateway passing the bearer token to the API in the Cloud Run instance without having to actually specify all of the individual endpoints and separate paths in the OpenAPI spec for the Gateway to match all of the endpoints in the APIs behind the Gateway

Is this generic/wildcard path spec possible at all?

Is there a way to pass the token through the Gateway without the Gateway trying to do anything with the token?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文