【发布时间】:2016-11-23 00:05:36
【问题描述】:
我们在 API Gateway 中为 Auth0 配置了一个自定义授权方。我们希望它根据调用它的阶段加载不同的配置值。有没有已知的处理方法?
【问题讨论】:
标签: amazon-web-services aws-api-gateway auth0
我们在 API Gateway 中为 Auth0 配置了一个自定义授权方。我们希望它根据调用它的阶段加载不同的配置值。有没有已知的处理方法?
【问题讨论】:
标签: amazon-web-services aws-api-gateway auth0
你有两个选择:
如果您想对两个阶段使用相同的授权函数,您可以解析包含该阶段的input passed to the function:
{
"type":"TOKEN",
"authorizationToken":"<caller-supplied-token>",
"methodArn":"arn:aws:execute-api:<regionId>:<accountId>:<apiId>/<stage>/<method>/<resourcePath>"
}
如果您想在每个阶段使用不同的函数,您可以使用阶段变量。 注意:您必须使用 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"}]'
【讨论】: