【问题标题】:CSRF Token has been associated to this client" without disabling CSRFCSRF 令牌已与此客户端关联”,但未禁用 CSRF
【发布时间】:2020-07-23 01:59:24
【问题描述】:

当我从客户端向服务器发出 DELETE 请求时,我遇到了错误。

"CSRF Token 已与此客户端关联" .响应代码:403 和响应标头

{
  "cache-control": "no-cache, no-store, max-age=0, must-revalidate",
  "content-length": "45",
  "content-type": "text/plain",
   "expires": "0",
  "pragma": "no-cache",
  "referrer-policy": "no-referrer",
  "x-content-type-options": "nosniff",
  "x-frame-options": "DENY",
 "x-xss-protection": "1 ; mode=block"
 }

如下所示,从 java 代码中禁用 CSRF 后,问题已解决。

  http.csrf( ).disable( ); 

但是禁用 CSRF 并不安全。您能帮我在不禁用 csrf 的情况下不要出现“CSRF Token has been associated to this client”错误吗?

谢谢

【问题讨论】:

    标签: spring-security csrf csrf-token


    【解决方案1】:

    我也遇到了这个问题,我得到的最简单的临时解决方案是在浏览器中禁用网络安全。

    创建目录

    e.g.
    /home/user/temp/google-chrome
    

    在禁用网络安全的情况下启动 chrome。

    google-chrome --user-data-dir=/home/user/temp/google-chrome --disable-web-security
    

    【讨论】:

      猜你喜欢
      • 2018-09-22
      • 2015-03-13
      • 2021-06-27
      • 2012-02-05
      • 2019-11-13
      • 2020-07-15
      • 2015-01-26
      • 2021-12-19
      • 2021-08-30
      相关资源
      最近更新 更多