简体   繁体   English

Spring Security - GET 请求上的 CSRF 令牌

[英]Spring Security - CSRF token on GET request

I configured CSRF protection in my Spring 5 (Boot 2) RESTful web service because I want to prevent CSRF attacks (I am using JWT cookie for authentication and authorization).我在 Spring 5 (Boot 2) RESTful Web 服务中配置了 CSRF 保护,因为我想防止 CSRF 攻击(我使用JWT cookie 进行身份验证和授权)。 On each request I am getting a new XSRF cookie.在每个请求中,我都会收到一个新的XSRF cookie。 The value of that cookie I am sending back through the X-CSRF-TOKEN header.我通过X-CSRF-TOKENX-CSRF-TOKEN回的那个 cookie 的值。

I noticed that POST , PUT and DELETE methods require the value of this token (in the X-CSRF-TOKEN header) in order to work properly, but GET method works just fine without X-CSRF-TOKEN header.我注意到POSTPUTDELETE方法需要这个令牌的值(在X-CSRF-TOKEN标头中)才能正常工作,但GET方法在没有X-CSRF-TOKEN标头的情况下工作得很好。

Is this behavior intentional because GET method should not change state or I did something wrong?这种行为是故意的,因为GET方法不应该改变状态或者我做错了什么?

CSRF 令牌被有意从 GET 中排除,以避免令牌泄漏给第三者

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

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