通过生成随机数令牌来防止 CSRF?
I was reading This article about preventing CSRF by creating a nonce token which going to be sent as variable in ajax function along with a session hold the same value as in the token. Is this a good idea because I realy don't like the useing of sessions specially with big website which has many active users all the time , which going to affect the general performance ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,只要您为每个用户提供独特的、不可猜测的价值,就不需要随机数。例如,它可以是
SHA1(user_id +“无人知道的秘密字符串”)
。我在另一个问题中回答了随机数和CSRF之间的区别:
https://stackoverflow.com/a/9803497/27009
No, nonce is not necessary as long as you'll have unique, unguessable value for each user. It could be for example
SHA1( user_id + "secret string nobody knows")
.I've replied about difference between nonces and CSRF in another question:
https://stackoverflow.com/a/9803497/27009