如何保护从 JQuery 调用的页面方法?
我刚刚开始使用 jquery 和静态页面后面的方法来启动 ajax。
由于 jquery 代码在客户端可见,请指导我如何隐藏页面 url 及其方法名称。我的意思是问,这个页面和静态方法是这样向所有人开放的,可以采取措施来保护它吗?
谢谢指导。
I just have started ajax using jquery and static page behind methods.
As jquery code is visible on client side, please guide how I can hide page url and its method name. I mean to ask is this way this page and static method is open to every one, can something be done to secure it ?
Thanks for guiding.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用常用的 HTTPS 协议来保护 AJAX 调用的安全,但不可能隐藏您正在调用的方法或 URL,至少完全隐藏它。当然,您可以使用 packer 之类的东西来混淆您的代码,但同样,正如您所说,因为 jQuery都是客户端,无论谁访问该页面都会知道发生了什么,至少在某种程度上。
You can secure an AJAX call using the usual HTTPS protocol, but its impossible to hide your method or URL you are calling, at least entirely hide it. You can obfuscate your code of course, using something like packer, but again, as you said, since jQuery is all client-side, whoever is accessing the page will know what's going on, at least to some extent.
不,绝对无法采取任何措施来“保护”它。您已将代码提供给客户。客户端需要能够执行代码。因此,客户需要能够理解代码。这样,你就骨头枯萎了。
只需拉起 FireBug、Fiddler、Charles 或任何其他调试代理即可立即告诉客户端 URL 是什么。
FireBug、Chrome开发者工具、IE开发者工具都会向你展示页面或对象中定义的所有JS方法。所以你在这方面也不走运。
JS“混淆”无论出于何种意图和目的都是毫无用处的。
No, absolutely nothing can be done to "secure" it. You've given the code to the client. The client needs to be able to execute the code. Thus, the client needs to be able to understand the code. Thus, you're boned.
Simply pulling up FireBug, Fiddler, Charles, or any other debugging proxy will tell the client immediately what the URL(s) are.
FireBug, Chrome Developer Tools, IE Developer Tools will all show you all the JS methods defined on a page or in an object. So you're out of luck on that count as well.
JS "obfuscation" is, for all intents and purposes, useless.