【问题标题】:Custom Authorizer + Stages configuration values自定义授权者 + 阶段配置值
【发布时间】:2016-11-23 00:05:36
【问题描述】:

我们在 API Gateway 中为 Auth0 配置了一个自定义授权方。我们希望它根据调用它的阶段加载不同的配置值。有没有已知的处理方法?

【问题讨论】:

    标签: amazon-web-services aws-api-gateway auth0


    【解决方案1】:

    你有两个选择:

    1. 如果您想对两个阶段使用相同的授权函数,您可以解析包含该阶段的input passed to the function

      {
        "type":"TOKEN",
        "authorizationToken":"<caller-supplied-token>",
        "methodArn":"arn:aws:execute-api:<regionId>:<accountId>:<apiId>/<stage>/<method>/<resourcePath>"
      }
      
    2. 如果您想在每个阶段使用不同的函数,您可以使用阶段变量。 注意:您必须使用 CLI 或 SDK 添加具有阶段变量的授权方。 CLI 示例:

      aws apigateway update-authorizer --rest-api-id <apidId> --authorizer-id <authorizerId> --patch-operations '[{"op":"replace","path":"/authorizerUri","value":"arn:aws:apigateway:<region>:lambda:path/2015-03-31/functions/arn:aws:lambda:<region>:<accountId>:function:${stageVaribles.authorizer}/invocations"}]'
      

    【讨论】:

    • 谢谢!我们选择了选项 1。我认为对于可能存在更多配置变动的大型部署#2 将需要部署脚本。
    • var methodArn = event.methodArn.split('/')[1] || “发展”;配置 = 环境[methodArn];
    猜你喜欢
    • 2018-10-01
    • 1970-01-01
    • 2022-12-04
    • 1970-01-01
    • 2017-05-20
    • 1970-01-01
    • 2017-07-02
    • 2018-08-07
    • 1970-01-01
    相关资源
    最近更新 更多