Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/weisjohn/superagent-csrf-middleware
easily handle CSRF tokens with superagent
https://github.com/weisjohn/superagent-csrf-middleware
Last synced: about 1 month ago
JSON representation
easily handle CSRF tokens with superagent
- Host: GitHub
- URL: https://github.com/weisjohn/superagent-csrf-middleware
- Owner: weisjohn
- License: mit
- Created: 2015-08-10T19:29:55.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-20T08:22:34.000Z (over 9 years ago)
- Last Synced: 2024-08-10T11:30:22.285Z (5 months ago)
- Language: JavaScript
- Size: 145 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# superagent-csrf-middleware
easily handle CSRF tokens with superagent
Supports simple CSRF implementations and those which modify the token with each request.
### usage
```javascript
var request = require('superagent');
var csrf = require('superagent-csrf-middleware');
var agent = request(server);var csrf1 = csrf();
agent.get('/foo')
.use(csrf1)
.end(function() {
agent.post('/bar')
.use(csrf1)
.end(function() {
/* ... */
});
});
```### options
By default, `superagent-csrf-middleware` looks at the `XSRF-TOKEN` cookie and sets the `X-XSRF-TOKEN` header.
You may optionally define other parameters:
```javascript
var cookie = 'MY-XSRF-COOKIE-NAME';
var header = '_SEASURF';
var csrf = require('superagent-csrf-middleware')(cookie, header);
```### support
This is known to work with [lusca](https://github.com/krakenjs/lusca)'s CSRF implementation.