POST方法,Ajax和安全性? [英] POST method, Ajax and Security?

查看:323
本文介绍了POST方法,Ajax和安全性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Ajax(jQuery的)和POST方法来更新数据库中的数据。我做到以下几点:

I use Ajax (jQuery) and the POST method to update data in the database. I do the following:

  • 获取从表单中的数据:USER_ID,entry_id,内容,...
  • 发送他们将处理数据的URL。
  • 如果数据是有效的,我们将在我们的数据库中记录它们。

我不知道如何验证用户从我的网站发送数据,而不是从其他地方。请帮我解决这个问题。谢谢!

I do not know how to verify that the user sends data from my website and not from other places. Please help me solve this problem. Thanks !

推荐答案

您正在尝试对 CSRF保卫攻击。

标准的防守是有一个要求在从不同的AJAX请求中检索到的POST的令牌。由于浏览器的跨域防御,Javascript的就是你的域之外将无法获得令牌。

The standard defense is to have a require a token in the POST that is retrieved from a different AJAX request. Because of the browser's cross-domain defenses, Javascript that is outside of your domain will not be able to get a token.

这篇关于POST方法,Ajax和安全性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆