1.1.1 • Published 7 years ago

csurf-noroutes v1.1.1

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

csurf with a ignoring routes ability

NPM Version NPM Downloads

Node.js CSRF protection middleware fork based on the csurf module.

Requires either a session middleware or cookie-parser to be initialized first.

If you have questions on how this module is implemented, please read Understanding CSRF.

Installation

$ npm install csurf-noroutes

API

var csurfNoRoutes = require('csurf-noroutes')

csurfNoRoutes(options)

Create a middleware for CSRF token creation and validation. This middleware adds a req.csrfToken() function to make a token which should be added to requests which mutate state, within a hidden form field, query-string etc. This token is validated against the visitor's session or csrf cookie.

Options

The csurf-noroutes function takes an optional options object that may contain any of the csurf legacy keys.

A new option is available

ignoreRoutes

an array of routes that you want the module to ignore when looking up for a valid CSRF (typically routes used by the POST method). This parameter supports the use of regular expressions to define url patterns.

With Strings :

{ignoreRoutes:['/my/first/route','/mySecond/route','etc..']}

With a Regex :

{ignoreRoutes:[/\/remoteCalls\/(.*)/g]}

Both :

{ignoreRoutes:['/remoteCalls/login',/\/remoteCalls\/(.*)/g]}

License

MIT

1.1.1

7 years ago

1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago