使用主干和 node.js 进行 CSRF 防御 [英] CSRF defense using backbone and node.js

查看:21
本文介绍了使用主干和 node.js 进行 CSRF 防御的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用主干和 node.js 创建一个网站,并且认为默认情况下没有针对 CSRF 的任何保护.在 node.js 中使用主干时,是否有针对 CSRF 进行项目的标准方法?谢谢

I'm creating a website using backbone and node.js and don't think that by default there is any protection against CSRF. Is there a standard way to project against CSRF when using backbone with node.js? Thanks

推荐答案

您可以简单地确保请求具有值为 XMLHTTPRequestX-Requested-By 标头.AJAX 请求具有跨域限制,因此如果该标头存在,则它不是例如恶意网站上的隐藏表单.

You could simply ensure requests have the X-Requested-By header with the value XMLHTTPRequest. AJAX requests have cross-domain restrictions so if that header is present it was not e.g. a hidden form on a malicious website.

这篇关于使用主干和 node.js 进行 CSRF 防御的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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