expressjs / csurf

CSRF token middleware
MIT License
2.3k stars 217 forks source link

Question: any harm in setting res.locals.csrfToken? #55

Closed zebapy closed 9 years ago

zebapy commented 9 years ago

Is there any harm with doing this so I can avoid having to put the csrfToken: req.csrfToken() in each res.render(...) in my Express app.

app.use(function(req, res, next) {
  res.locals.csrfToken = req.csrfToken();
  next();
});

Thanks

dougwilson commented 9 years ago

No harm, though you may eat up your entropy pool quicker and slightly slow all requests down, even those that do not need that token. It is a method instead of a property because calling it does work.

anyong commented 8 years ago

This issue is more than a year old but just curious - how many requests are we talking about where it may become a problem and begin to slow down?