从API Gateway,我使用python中的Lambda函数为我的API创建了一个自定义授权者。API网关使用我配置的标头移交传入的身份验证令牌method.request.header.Authorization
。但是,我还需要在lambda函数中使用原始http请求的其他标头。如何访问它们?我没有在event
输入到lambda函数的对象上看到标题。
请注意,这与“如何使用Lambda如何访问HTTP头以请求AWS API Gateway的请求”不是重复的?。问题是关于自定义授权者lambda函数。我看不到任何将传入的HTTP标头传递给授权方lambda函数的配置选项。
根据AWS文档,API Gateway会使用以下输入来调用Custom Authorizer。基于以下内容,我认为我的询问是不可能的。但是要检查是否有解决方法。
{ “ type”:“ TOKEN”, “ authorizationToken”:“”, “” methodArn“:” arn:aws:execute-api:<regionId>:<accountId>:<apiId> / <stage> / <method> / <resourcePath>“ }
现在可以通过使用“请求”类型的授权者而不是令牌来实现
完整的详细信息在这里:https : //docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html
从根本上讲,所有标头都在事件对象中传递以获得请求授权
即事件上的标头对象
"headers": {
"X-wibble": "111",
"X-wobble": "222",
"x-amzn-ssl-client-hello": "*Deleted*",
"Via": "1.1 .cloudfront.net (CloudFront)",
"CloudFront-Is-Desktop-Viewer": "true",
"CloudFront-Is-SmartTV-Viewer": "false",
"CloudFront-Forwarded-Proto": "https",
"X-Forwarded-For": "*Deleted*",
"CloudFront-Viewer-Country": "GB",
"Accept": "*/*",
"User-Agent": "curl/7.55.1",
"X-Amzn-Trace-Id": "Root=*Deleted*",
"Host": "*Deleted*.execute-api.eu-west-1.amazonaws.com",
"X-Forwarded-Proto": "https",
"X-Amz-Cf-Id": "*Deleted*",
"CloudFront-Is-Tablet-Viewer": "false",
"X-Forwarded-Port": "443",
"CloudFront-Is-Mobile-Viewer": "false"
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句