首先,服务端nginx等需要设置跨域请求以及跨域frame请求是否允许(默认都是不允许的)。
再者,浏览器端对跨域ajax限制非常严格,根本不允许跨域访问cookie。
那么我们web开发时,现在对csrf所做的措施(一般是给form 加个hidden csrf token input),是否是多此一举了,完全没必要?
<code class="language-html"><span class="nt"><form> <span class="na">action=</span><span class="s">"no-csrf-token/reset-password"</span> <span class="na">method=</span><span class="s">"post"</span><span class="nt">></span> <span class="nt"><input> <span class="na">type=</span><span class="s">"hidden"</span> <span class="na">name=</span><span class="s">"password"</span> <span class="na">value=</span><span class="s">"password123"</span><span class="nt">></span> <span class="nt"><input> <span class="na">type=</span><span class="s">"hidden"</span> <span class="na">name=</span><span class="s">"repassword"</span> <span class="na">value=</span><span class="s">"password123"</span><span class="nt">></span> <span class="c"><!-- 更多的隐藏input --></span> <span class="nt"><button> <span class="na">type=</span><span class="s">"submit"</span><span class="nt">></span>点击送话费<span class="nt"></span></button></span> <span class="nt"></span></span></span> </form></span> </code>