【问题标题】:Is there REST API key equivalent in HTTP API Gateway?HTTP API 网关中是否有等效的 REST API 密钥?
【发布时间】:2021-11-22 11:59:51
【问题描述】:

使用 REST API (AWS API Gateway v1),我们可以在请求中使用 X-API-Key 标头并维护 API 密钥来控制对给定端点的访问。

在 AWS 中,如果我转到 API Gateway 并选择 REST API (v1),然后在 Resources 下我看到:API Key Required 在 API Keys 下我可以找到我的密钥。

使用serverless可以这样配置:

provider:
  apiKeys:
    - my-api-key

functions:
  hello:
    handler: handler.hello
    events:
      - http:
          path: /hello
          method: get
          private: true

但如果我切换到httpApi,我会得到:

Configuration warning at 'functions.hello.events[0].httpApi': unrecognized property 'private'

此外,在 API Gateway 中,在 HTTP API (v2) 下,任何地方都没有 API 密钥。

当我查看文档时,在 REST API 下有一个关于 API Keys 的重要部分: https://www.serverless.com/framework/docs/providers/aws/events/apigateway 但 API Gateway HTTP API 与 API 密钥无关: https://www.serverless.com/framework/docs/providers/aws/events/http-api

HTTP API (API Gateway v2) 中是否有 REST API (API Gateway v1) API 密钥等效?基本上,我希望能够像在 REST API 中一样将X-API-Key 与 HTTP API 一起使用。

【问题讨论】:

    标签: amazon-web-services rest aws-api-gateway serverless aws-http-api


    【解决方案1】:

    我可以考虑一些解决方法(使用自定义授权方),在使用 AWS API Gateway v2(HTTP API)时模仿 API 密钥功能,但不会接近 v1(REST API),所以简短的回答是 没有没有等价物。

    Choosing between HTTP APIs and REST APIs 中有一个 API 管理表清楚地显示 API 密钥在 HTTP API 中支持。

    此外,来自同一个文档:

    上一代 REST API 目前提供更多 功能。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-13
      • 2018-03-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多