是否可以阻止 RESTful API 中的批量查询?
我想问一下,如果可能的话,防止坏用户对我的 RESTful Web API 进行多次查询。这是我的情况:
我的客户端应用程序向 Web API 进行查询。该查询由产品的 EAN 代码组成。服务器回复产品参数和其他产品信息。现在,我试图防止的是,我的竞争对手(坏用户)窃取我需要手动收集的宝贵数据。问题是,BAD 用户拥有所有 EAN 代码的列表,并且可以进行自动查询以从我的 API 获取所有数据。
I would like to ask, if it is possible, to prevent BAD users doing many queries to my RESTful web API. Here is my situation:
My client app makes a query to web API. This query consists of EAN code of a product. Server replies with product parameters and other product information. Now, what I am trying to prevent is, my competitor (BAD user) to steal precious data which I needed to gather manually. The problem is, that BAD user has the list of all the EAN codes and can do automatic queries to get all the datas from my API.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
限制它们,以便它们每分钟只能请求 x 次……也许通过最终用户必须注册的身份验证令牌或 API 密钥。或者,如果您认识他们,也可以将他们的 IP 全部列入黑名单。
Throttle them so they can only request x times per ip/per minute...perhaps by an auth token or API key that end users would have to register for. Or you can just blacklist their IP's all together if you know them.
让 API 用户自行注册并将 API 密钥分发给每个人。如果您愿意,密钥可以是 URL 的一部分。这样,您就可以跟踪哪些用户正在做什么,并根据需要设置使用限制。
Make the API users register themselves and hand out API keys to everyone. the key can be part of the URL if you like. That way, you can track which users are doing what, and have usage limits if you want.
当然,您需要对 API 实施安全保护。不允许匿名访问您的资源或 API,并确保只有您的“好”客户端才有权调用它们。 HTTPS 基本身份验证以及传输层的 SSL 加密就可以解决问题,或者让他们在请求中指定秘密客户端密钥。
Sure, you need to apply security to your APIs. Don't allow anonymous access to your resources or APIs and make sure that only your "good" clients have the permissions to call them. HTTPS basic authentication along with SSL encryption at the transport layer would do the trick, or have them specify a secret client key as part of the request.