我在从我定义的授权方 lambda 中的请求对象获取
methodArn
时遇到问题。我正在使用带有 golang 的无服务器。这是我拥有的代码的编辑设置。
main.go - 授权处理函数
func Handler(request events.APIGatewayCustomAuthorizerRequestTypeRequest) (events.APIGatewayCustomAuthorizerResponse, error) {
// I have tried logging the entire request to cloud watch, see further down for the sample
// i have code here to verify a jwt token
return nil, nil
}
serverless.yml - 我的无服务器设置来注册函数并定义授权者
functions:
permission_verify:
handler: bin/handlers/permission/verify
package:
patterns:
- "!./**"
- ./bin/**
provider:
httpApi:
authorizers:
custom:
functionName: permission_verify
type: request
通过上述设置,我可以在其他微服务中使用授权者来验证
jwt
令牌,但现在我想向授权者添加更多功能,因此我需要请求中的methodArn
存在。
这里是云监视在到达使用授权方的端点后的输出
cloud watch - 请求 json
{
"type": "REQUEST",
"methodArn": "",
"resource": "",
"path": "",
"httpMethod": "",
"headers": {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"authorization": "redacted",
"content-length": "redacted",
"content-type": "application/json",
"host": "redacted",
"postman-token": "redacted",
"user-agent": "PostmanRuntime/7.31.3",
"x-amzn-trace-id": "redacted",
"x-forwarded-for": "redacted",
"x-forwarded-port": "443",
"x-forwarded-proto": "https"
},
"queryStringParameters": null,
"pathParameters": null,
"stageVariables": null,
"requestContext": {
"path": "",
"accountId": "redacted",
"resourceId": "",
"stage": "$default",
"requestId": "redacted",
"identity": {
"apiKey": "",
"sourceIp": ""
},
"resourcePath": "",
"httpMethod": "",
"apiId": "redacted"
}
}
我已经在互联网上搜索了一个解释和原因,因为在请求中没有关于调用 lambda 的信息无济于事。已经有相当长的时间了,我们将不胜感激任何帮助。