【发布时间】:2019-04-29 08:49:10
【问题描述】:
对于 Kinesis 流,我使用 AWS API Gateway 创建了一个代理 API。我使用 python Lambda 为代理添加了一个自定义授权方。
在发布 lambda 函数并部署 API 后,我能够使用网关测试功能成功测试 API。我可以在 cloudwatch 中看到日志,其中包含来自自定义 auth lambda 函数的详细打印。认证成功后,API Gateway 将记录推送到我的 Kinesis 流
但是,当我从 Chrome Postman 客户端调用相同的 API 时,我得到 500 Internal Server Error 并且响应标头包括 X-Cache → Error from cloudfront, x-amzn-ErrorType → AuthorizerConfigurationException
Lambda 身份验证函数返回允许对我的 API 执行请求的策略。返回的政策文件是:
{ “政策文件”:{ “版本”:“2012-10-17”, “陈述”: [ { “动作”:“执行 API:调用”, “资源”:[ “arn:aws:execute-api:us-east-1:1234567:myapiId/staging/POST/*” ], “效果”:“允许” } ] }, “principalId”:“Foo” }为什么来自 Chrome 或 curl 的请求失败,但在 API Gateway 中同样的 API 测试工作正常?
【问题讨论】:
-
这本质上意味着您的授权方没有返回策略或返回无效策略或返回未授权 API 请求的策略。如果未返回策略,授权代码将因某种原因失败...
标签: amazon-web-services aws-lambda aws-api-gateway custom-authentication