[英]Custom Authorizer not working when used with AWS Chalice
我正在使用 AWS 自定义授权程序来保护 lambda 函数。 由于一些配置问题,我无法使用自定义授权方。
当我尝试从 API Gateway 控制台附加授权方时,它工作正常。 当从代码附加授权人时,它不会给出任何错误。 我尝试检查 cloudwatch 日志,未为 lambda 函数(授权方和 helloworld 函数)生成日志。
下面是我编写的示例代码:
from chalice import Chalice
from chalice import CustomAuthorizer
app = Chalice(app_name='helloworld-python')
authorizer = CustomAuthorizer(
'MyCustomAuth', header='Authorization',
authorizer_uri=('arn:aws:apigateway:{region}:lambda:path/2015-03-31'
'/functions/arn:aws:lambda:{region}:{account-id}:'
'function:{function-name}/invocations'))
@app.route('/test/test_authorizer', authorizer=authorizer)
def index():
return {'hello': 'world'}
我已经配置了以下策略:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"execute-api:Invoke"
],
"Resource": [
"*"
]
}
]
}
我无法将授权方添加到 lambda 函数。 当我触发端点时,它给了我以下错误:
端点:https://{rest-api-id}.execute-api.{region}.amazonaws.com/dev/test/test_authorizer
Http方法:GET
错误代码:500。
错误正文:
{ "message": null }
我怎样才能做到这一点。 请向我提供适当的情报。
看到这个问题: https : //github.com/aws/chalice/issues/670#issuecomment-573637135
或者,有一个解决方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.