简体   繁体   English

客户端API安全

[英]Client side API security

I was implementing Olark live chat on my website and all I had to do is implement following js code. 我正在网站上实现Olark在线聊天,而我要做的就是实现以下js代码。

  <script type="text/javascript" async>
      ;(function(o,l,a,r,k,y){if(o.olark)return;
      r="script";y=l.createElement(r);r=l.getElementsByTagName(r)[0];
      y.async=1;y.src="//"+a;r.parentNode.insertBefore(y,r);
      y=o.olark=function(){k.s.push(arguments);k.t.push(+new Date)};
      y.extend=function(i,j){y("extend",i,j)};
      y.identify=function(i){y("identify",k.i=i)};
      y.configure=function(i,j){y("configure",i,j);k.c[i]=j};
      k=y._={s:[],t:[+new Date],c:{},l:a};
      })(window,document,"static.olark.com/jsclient/loader.js");

      /* Add configuration calls below this comment */
      olark.identify('XXXX-XXX-XX-XXXX');
  </script>

I am wondering what technique uses Third Party JavaScript plugin like Olark , Disqus and similar companies? 我想知道哪种技术使用第三方JavaScript插件,例如OlarkDisqus和类似公司?

As you can see olark.identify() is public available on my web page and you can find it with "inspect element". 如您所见, olark.identify()在我的网页上是公开可用的,您可以使用“检查元素”找到它。 So how they handle security and bounce unwanted requests? 那么他们如何处理安全性并反弹不必要的请求呢?

  olark.identify('XXXX-XXX-XX-XXXX');

It's a fairly broad question, but I'll make an attempt to answer: 这是一个相当广泛的问题,但我将尝试回答:

Lots of these tools don't really block unwanted requests. 这些工具中的许多工具并没有真正阻止不需要的请求。 For example, it's possible to embed a disqus comment block on a completely unrelated website. 例如,可以在完全不相关的网站上嵌入Disqus评论块。

I don't think this is the worst thing, because: what's the issue with comments showing up somewhere else? 我不认为这是最糟糕的事情,因为:评论出现在其他地方是什么问题? It was already public information to begin with. 首先已经是公共信息。

Scripts that need to prevent exactly which domain they are embedded in tend to use CORS and the Origin header to make sure of this. 需要准确防止嵌入它们的域的脚本倾向于使用CORS和Origin头来确保这一点。 Alternatively, they can use the information from document.location . 或者,他们可以使用document.location的信息。

This is not 'hard' security in a sense that it completely disables mis-use, but it uses the browser sandbox to make it a lot harder to abuse. 从某种意义上说,这不是“硬性”安全性,它可以完全禁止滥用,但是它使用浏览器沙箱使其变得更难滥用。

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

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