I'm setting up Stripe to work with my sails.js server, and in order to use Stripe's webhooks, I need to disable CSRF for the URLs I provide to Stripe.
Is it possible to make certain URLs exempt from CSRF POST requirements in sails.js? The only configuration I can find for CSRF is to turn it on globally, and looking through the source code for the csrf hook (https://github.com/balderdashy/sails/blob/master/lib/hooks/csrf/index.js) it looks like if I try to provide a custom object, it just gets replaced with the global settings anyway.
Thanks
So Murcho's solution is working but actually, sails v0.11 has a config file just for that :
In config/csrf.js
, after the line where you activate csrf protection lies this comments block :
/****************************************************************************
* *
* You may also specify more fine-grained settings for CSRF, including the *
* domains which are allowed to request the CSRF token via AJAX. These *
* settings override the general CORS settings in your config/cors.js file. *
* *
****************************************************************************/
// module.exports.csrf = {
// grantTokenViaAjax: true,
// origin: ''
// }
You just need to add a config object there to extend the defaults :
module.exports.csrf = {
"routesDisabled": "/webhooks/testhook,/webhooks/anotherhook"
}