简体   繁体   English

angular7 中的 CSRF 攻击

[英]CSRF attack in angular7

How to prevent CSRF attack in angular7 when I use XMLHttpRequest使用 XMLHttpRequest 时如何防止 angular7 中的 CSRF 攻击

let xhr = new XMLHttpRequest();让 xhr = 新的 XMLHttpRequest(); var inputData = {}; var inputData = {};

xhr.open('POST', this.hostUrlConstants["baseUrl"] + this.pathUrlConstants["xxxx"] + this.pathUrlConstants["yyy"] + "/" + scenarioId, true);

Fortunately, this request will not be executed by modern web browsers thanks to same-origin policy restrictions.幸运的是,由于同源策略限制,现代网络浏览器不会执行此请求。 This restriction is enabled by default unless the target web site explicitly opens up cross-origin requests from the attacker's (or everyone's) origin by using CORS with the following header:默认情况下启用此限制,除非目标网站通过使用带有以下标头的 CORS 明确打开来自攻击者(或每个人)来源的跨域请求:

Access-Control-Allow-Origin: *访问控制允许来源:*

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

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