【问题标题】:How to configure serverless framework HttpApi Authorizer for custom lambda authorizer如何为自定义 lambda 授权器配置无服务器框架 HttpApi Authorizer
【发布时间】:2022-01-14 17:58:49
【问题描述】:

在文档中有关于如何配置授权者的信息,例如 Cognito:

https://www.serverless.com/framework/docs/providers/aws/events/http-api#jwt-authorizers

这是它的副本:

  httpApi:
    authorizers:
      someJwtAuthorizer:
        identitySource: $request.header.Authorization
        issuerUrl: https://cognito-idp.${region}.amazonaws.com/${cognitoPoolId}

有人知道如何为我自己编写的自定义 lambda jwt 授权器进行配置吗?

【问题讨论】:

  • 在撰写此评论时,尽管 AWS 支持无服务器框架,但这是不可能的。

标签: serverless-framework serverless


【解决方案1】:

我只使用之前为 httpApi 创建的 JWT Authorizer 实现了它,但必须与自定义 Lambda Authorizer 类似(从未使用过)

      - httpApi:
          method: any
          authorizer: # https://github.com/serverless/serverless/issues/7598
            # Provide both type and authorizerId
            type: COGNITO_USER_POOLS # TOKEN or REQUEST or COGNITO_USER_POOLS, same as AWS Cloudformation documentation
            id: <AUTHORIZER ID>  # or authorizer name "name: my-lambda"
            scopes: # Optional - List of Oauth2 scopes when type is COGNITO_USER_POOLS
              - my-resource-server/my-grant-type
          path: /{proxy+}

这里有更多关于这个问题的信息:

AWS HTTP API: Support IAM and Lambda authorizers #8210

feat(AWS HTTP API): Add support for custom Lambda authorizers #9192

【讨论】:

  • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
【解决方案2】:

查看Serverless docs for API Gateway,其中显示了使用自定义授权者的几个示例。

【讨论】:

  • 据我所见,有很多示例,但它们是针对代表 Rest 类型 API 网关的 Http 的。我所追求的是 HttpApi 的示例。
  • @Efe 你解决了吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-05-01
  • 2018-08-27
  • 2019-12-15
  • 2020-02-02
  • 2020-03-16
  • 2020-05-28
  • 2020-11-08
相关资源
最近更新 更多