web-interview icon indicating copy to clipboard operation
web-interview copied to clipboard

[网络] 50. cookie 和 token 都存放在 header 中,为什么不会劫持 token?

Open qiilee opened this issue 5 years ago • 1 comments

qiilee avatar Feb 24 '20 05:02 qiilee

浏览器发送请求的时候不会自动带上token,而cookie在浏览器发送请求的时候会被自动带上。

csrf就是利用的这一特性,所以token可以防范csrf,而cookie不能。

JWT本身只关心请求的安全性,并不关心toekn本身的安全。

HYzoro avatar Oct 14 '20 03:10 HYzoro