最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

node.js - CSRF protection in node - Stack Overflow

programmeradmin1浏览0评论

So I am developing a small auth-module for an application of mine, mainly to learn how session based auth really works.

I thought it would be cool if it could also provide csrf protection, so I kinda dug into the topic and got extremely confused.

From my understanding, the csrf-token is created at the beginning of the session and than saved in a db on the server and a cookie on the client side. Now on every request, the csrf token is sent through a header by the client.

Is it better to provide a new token per request?

I thought about using the csrf module to create a secret and than hash it with a salt on every request, but that introduces a whole lot of new problems:

Will the latency be too high? What to do if there hasn't been a request already through which the token has been sent?

发布评论

评论列表(0)

  1. 暂无评论