如何安全地跨脚本(思考分析)
这个周末我正在构建一种有趣的分析平台,这是我想要的效果。
客户:abc.com 服务器:test.com
客户端通过 javascript id 向服务器发送: 12345,以及浏览器信息。服务器响应一个新的 id(例如:#23456),然后将其推送到当前 url (pushstate) http:// abc.com/#23456
我正在考虑客户端从服务器包含的某种与服务器后端通信的脚本,但这在技术上不是 XSS 且不安全吗?分析人员(Google、GetClicky 等)如何做到这一点?!
我怎样才能像分析网站那样实现这一点,这样互联网之神就不会因为 XSS 而生我的气,同时仍然保持安全性和易于实施。其中一份包含来源。
我希望您能做任何事情来为我指明正确的方向。
I'm building a sort of analytics platform for fun this weekend and here is my desired effect.
Client: abc.com
Server: test.com
User visits http://abc.com/#12345
Client sends Server via javascript id: 12345, and browser information. Server responds with a new id (ex: #23456), which is then pushed onto the current url (pushstate) http://abc.com/#23456
I was thinking of some kind of script that the Client includes from the Server that communicates with the servers backend, but is that not techincally XSS and unsecure? How do analytics people (Google, GetClicky, etc) do it?!
How can I achieve this like analytics sites do so the internet gods don't get mad at me for XSS, while still maintaing security, and ease of implementation. One included source.
I'd love anything you can do to point me in the right direction.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与 jsonp.这个想法是,脚本标签的源是您想要执行的代码:
编辑:是的,您动态创建类似于 ajax 响应的脚本:
在您的 php 页面内:
无论如何,类似的东西。
编辑:完全忘记了,但是 jsonp 的要点是你传入一个回调函数。请参阅此处了解一些 php 文档: http://php.net/manual/en/ function.json-encode.php
With jsonp. The idea is that the source of a script tag is the code you want to execute:
edit: Yes, you create the script dynamically similar to an ajax response:
Inside your php page:
Something of the sort, anyway.
edit: completely forgot, but the point of jsonp is that you pass in a callback function. See here for some php documentation: http://php.net/manual/en/function.json-encode.php