简体   繁体   English

eBay API-在JavaScript应用程序中保护AppID

[英]eBay API - securing AppID in a JavaScript application

I am about to publish a demo JavaScript application based on eBay finding API on my personal website; 我即将在我的个人网站上发布一个基于eBay查找API的演示JavaScript应用程序; I was wondering if there is a way to prevent my AppID from being read and exploited. 我想知道是否有一种方法可以防止我的AppID被读取和利用。 Is it possible to associate the AppID to a specific domain ? 是否可以将AppID关联到特定域? I haven't been able to find an answer neither on eBay Developer Forums nor in the official documentation. 我既没有在eBay开发者论坛上也没有在官方文档中找到答案。

If you send data to the client, the client can read the data. 如果您将数据发送到客户端,则客户端可以读取数据。 There is no way to prevent this (if JavaScript can decode it, so can the user). 无法阻止这种情况(如果JavaScript可以解码,那么用户也可以)。 In order to avoid that, you need to keep the data (your AppID) on your site, and process the request on your server. 为了避免这种情况,您需要将数据(您的AppID)保留在您的站点上,并在服务器上处理请求。 So the JavaScript needs to talk to your server, and your server will then pass on the request to eBay, adding the AppID, and then pass the results back to the JavaScript. 因此,JavaScript需要与您的服务器通信,然后服务器将请求传递给eBay,添加AppID,然后将结果传递回JavaScript。

To answer your question... 要回答您的问题...

It doesn't seem possible to restrict AppIDs as the limits don't work on a per-site basis like that and you usually have just one AppID for all your uses/sites. 似乎无法限制AppID,因为这样的限制对每个站点都不起作用,并且通常只有一个AppID可用于所有用途/站点。 See this comprehensive thread from 2010 (quoted below), I doubt much has changed. 看到2010年的这个综合性话题 (在下面引用),我怀疑是否已经改变了。 The end result is it basically doesn't matter for a read-only application such as search results on your website. 最终结果是,对于只读应用程序(例如您网站上的搜索结果)基本上没有关系。

More generally about securing JSON API calls in-browser 更一般而言,有关确保浏览器中的JSON API调用的安全

Checking the referrer is the best way to secure an otherwise public API. 检查引荐来源网址是保护其他公共API的最佳方法。 This is how Google restricts their API keys for maps, for instance: https://developers.google.com/maps/documentation/javascript/tutorial 这就是Google限制其API密钥用于地图的方式,例如: https : //developers.google.com/maps/documentation/javascript/tutorial

About the only thing that will prevent fraud is activity monitoring, given that the API is called from third-party computers, one would have to track trends for abuse, perhaps by comparing a list of calls to other website activity, or by using JSONP to inspect the browser's properties with AJAX. 关于防止欺诈的唯一方法是活动监视,因为该API是从第三方计算机调用的,因此可能必须跟踪滥用趋势,方法可能是将调用列表与其他网站活动进行比较,或者使用JSONP进行跟踪。使用AJAX检查浏览器的属性。 Google can cross-reference their API calls with their Google Analytics calls, for example, though there could always be false positives. 例如,尽管总是存在误报,但Google可以将其API调用与Google Analytics(分析)调用交叉引用。

In the end, if the fear is CSRF, there's this: How to reliably secure public JSONP requests? 最后,如果担心是CSRF,那就是: 如何可靠地保护公共JSONP请求?

Quoting verbatim from the eBay thread in case the URL changes again: 如果URL再次更改,请从eBay线程逐字引用:

There is one DevID per developer account. 每个开发人员帐户只有一个DevID。

There could be multiple AppID, but these are only available via paid support ticket. 可能有多个AppID,但只能通过付费支持票获得。

Each AppID can have multiple CertID. 每个AppID可以具有多个CertID。 The CertID determines your call limits. CertID确定您的通话限制。

You can generate unlimited tokens for each AppID. 您可以为每个AppID生成无限令牌。 Each token is a pairing of AppID, UserID, and the associated eBay user's password. 每个令牌都是一对AppID,UserID和关联的eBay用户密码。 Tokens are currently active for 18 months. 令牌目前有效期为18个月。 They must then be regenerated. 然后必须重新生成它们。 Tokens can also be prematurely 'revoked' either via the API or website preferemces. 令牌也可以通过API或网站偏好来过早地“撤销”。

For the API families that require a token, you can use a single token based on your own UserID to retrieve most public information. 对于需要令牌的API系列,您可以根据自己的UserID使用单个令牌来检索大多数公共信息。 However, private transaction details are only available when you use a token generated for the target UserID. 但是,仅当您使用为目标UserID生成的令牌时,私人交易详细信息才可用。 Some calls actually derive the UserID from the token. 某些调用实际上是从令牌中派生UserID的。

If multiple applications share the same AppID, they will both contribute towards the daily call limits. 如果多个应用程序共享相同的AppID,则它们都将影响每日通话限制。 That's why you might want to request a separate AppID. 这就是为什么您可能想要请求一个单独的AppID的原因。

https://www.x.com/developers/ebay/ebay-api-call-limits https://www.x.com/developers/ebay/ebay-api-call-limits

The limits shown in the chart are 'aggregate' for the given API family. 图表中显示的限制是给定API系列的“汇总”。 There's an implicit per-AppID. 每个AppID都有一个隐式。 For the Trading API, eBay further limits use on a per-call or per-time-interval basis. 对于Trading API,eBay进一步限制了每次通话或时间间隔的使用。 Some calls like AddItem have higher limits. 某些调用(例如AddItem)具有更高的限制。 GetApiAccessRules will return your actual limits and usage. GetApiAccessRules将返回您的实际限制和使用情况。

Per-IP-address means the IP address of the calling machine. 每个IP地址表示呼叫机器的IP地址。 If you were to rotate through multiple IP addresses, you'd actually multiply your limit. 如果要轮流浏览多个IP地址,则实际上是要乘以上限。 There are many read-only 'widgets' written in JavaScript or Flash which run in the client browser and thus use the client IP to make the calls. 在客户端浏览器中运行着许多用JavaScript或Flash编写的只读“部件”,因此使用客户端IP进行呼叫。 In that case, the call limit is pretty insignificant. 在这种情况下,通话限制微不足道。

AppID, DevID and CertID belong to the creator of the developer account. AppID,DevID和CertID属于开发人员帐户的创建者。 That creator is bound by the API license provisions. 该创建者受API许可条款的约束。

As the owner of the keys, you are not to allow any 3rd-party programmatic control of the API. 作为密钥的所有者,您不允许任何第三方的API编程控制。 Strictly speaking, that means that both the keys and any token derived from those keys should remain private (ie under your exclusive control). 严格来说,这意味着密钥和从这些密钥派生的任何令牌都应保持私有(即在您的独占控制之下)。

Obviously, eBay does not enforce that strict interpretation since FetchToken is suggested for client-side applications. 显然,由于建议将FetchToken用于客户端应用程序,因此eBay不会执行严格的解释。 A sophisticated user could easily grab the token coming or going. 经验丰富的用户可以轻松掌握即将来临的令牌。 What harm can someone do with a token based on their own UserID? 某人根据自己的UserID使用令牌会带来什么危害?

  1. Burn through your daily call limit 耗尽您的每日通话限制
  2. Create an API application that violates the license 创建违反许可证的API应用程序

For more of the debate, see this earlier thread. 有关更多辩论,请参阅此较早主题。 (Link broken) (链接断开)

Once your application passes the eBay Compatible Application Check, you can request either 1.5M shared or 20K calls per user. 一旦您的应用程序通过了eBay兼容应用程序检查,您就可以请求每个用户150万个共享呼叫或2万个呼叫。

For further information about eBay's APIs, I suggest asking on their forum . 有关eBay API的更多信息,建议在其论坛提问

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

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