简体   繁体   English

如何限制从 API 网关到 AWS Lambda 的负载中的特定参数?

[英]How can I restrict specific parameters in payload from API Gateway to AWS Lambda?

I have to send a request body (payload) from API Gateway to AWS Lambda. In that payload, I only need to send:我必须从 API 网关向 AWS Lambda 发送请求正文(有效负载)。在该有效负载中,我只需要发送:

{
    "path":"aaa"
    "action":"xyz"
}

If someone passes any other parameter in the payload, it should not accept the payload and show an error message.如果有人在有效载荷中传递任何其他参数,它不应该接受有效载荷并显示错误消息。 Could somebody please help me with the logic?有人可以帮我解决逻辑问题吗?

For AWS API Gateway you can implement request validation using an OpenAPI template.对于 AWS API 网关,您可以使用 OpenAPI 模板实施请求验证。 The extension should work for both Rest and Http APIs.该扩展应该适用于 Rest 和 Http API。

For even more flexibility you could implement a Lambda authorizer which evaluates the body, but of course this leads to more costs as well:为了获得更大的灵活性,您可以实施一个 Lambda 授权方来评估主体,但这当然也会导致更多成本:

https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 AWS API 网关时,是否可以从自定义 Lambda 授权方传回 JWT 有效负载? - Is it possible to pass back JWT payload from custom Lambda authorizer when using AWS API Gateway? 我无法从 VPC 内部访问 AWS API 网关 - I can't access an AWS API Gateway from inside a VPC 如何在代理和 API 网关后面将 API 请求 (AWS SigV4) 签名到 Lambda? - How do I sign API requests (AWS SigV4) to Lambda behind Proxy & API Gateway? 如何拒绝对 AWS API 网关的公共访问? - How can I deny public access to an AWS API gateway? 如何使用 API 网关集成访问 Node js AWS Lambda 中的 POST 参数? - How do I access a POST parameter in Node js AWS Lambda with API Gateway integration? AWS - 从公共 API 网关路由到 VPC 内 lambda - AWS - Route from public API Gateway to in-VPC lambda AWS Api Gateway Lambda代理集成,如何从客户端请求中获取源端口 - AWS Api Gateway Lambda proxy integration, how to get source port from client request 如何使用 Lambda 访问 AWS API Gateway 请求的 HTTP 标头? - How to access HTTP headers for request to AWS API Gateway using Lambda? 如何在aws中获取api网关密钥名称 lambda function - How to get api gateway key name in aws lambda function terraform - 从文件定义 aws api 网关请求参数? - terraform - define aws api gateway request parameters from file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM