简体   繁体   English

使用GET参数限制AWS API Gateway端点

[英]Limt AWS API Gateway endpoint with GET parameters

I have an API Gateway endpoint at some url, like this: 我在某些网址处有一个API网关端点,如下所示:

https://api.myapp.com/myendpoint

The people and/or services that are going to be accessing this endpoint need to pass particular parameters and values to the endpoint. 将要访问此端点的人员和/或服务需要将特定的参数和值传递给端点。 Like this: 像这样:

https://api.myapp.com/myendpoint?token=123456

Is it possible to limit access to the endpoint if the token parameter is missing OR if the token value is not a specific pre-determined value? 如果缺少token参数,或者token值不是特定的预定值,是否可以限制对端点的访问? Can I setup my endpoint to simply ignore calls that don't have the proper token? 我可以将端点设置为简单地忽略没有正确令牌的呼叫吗?

I'm planning on using Lambda as the backend. 我打算使用Lambda作为后端。 Do I have to deal with this in my Lambda function? 我必须在Lambda函数中处理此问题吗? Ultimately, I'm trying to avoid unnecessary Lambda and API Gateway usage costs by random individuals making bogus calls to the endpoint. 最终,我试图避免由随机的个人对端点进行虚假调用来避免不必要的Lambda和API网关使用成本。 So if I can have API Gateway simply ignore these calls without spinning up Lambda that would be ideal. 因此,如果我可以让API Gateway不用理会Lambda而不必理会这些调用,那将是理想的选择。

If I am able to have API Gateway ignore these calls, do I still get billed for usage when bogus calls are made to the endpoint(s) that are missing the token? 如果我能够让API Gateway忽略这些调用,当对缺少令牌的端点进行虚假调用时,是否仍需为使用付费?

The reason I'm asking is because the 3rd party service that is going to access this endpoint does not have any options for passing authentication parameters in headers or using AWS Cognito, etc. So I'm just trying to think of a simple way to limit access. 我问的原因是因为要访问此终结点的第三方服务没有任何选项可用于在标头中传递身份验证参数或使用AWS Cognito等。因此,我只是在尝试一种简单的方法来限制访问。

You will need to perform this validation in Lambda. 您将需要在Lambda中执行此验证。

If you have a mapping for a query parameter token to the integration endpoint, then for a request like ...?token=123 API Gateway will pass the parameter to the endpoint, but for ...?token= , API Gateway will not. 如果您有一个查询参数token到集成端点的映射,那么对于诸如...?token=123的请求,API Gateway会将参数传递给端点,但是对于...?token= ,API Gateway不会。

API gateway does not do validation of query parameters like you want and you will be billed for the requests. API网关不会像您所希望的那样对查询参数进行验证,因此会向您收取请求费用。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM