1.3.0 • Published 10 years ago
@npmcorp/blankie v1.3.0
blankie
A CSP plugin for hapi.
Usage
This plugin depends on scooter to function.
To use it:
var Hapi = require('hapi');
var Blankie = require('blankie');
var Scooter = require('scooter');
var server = new Hapi.Server();
server.register([Scooter, {
register: Blankie,
options: {} // specify options here
}], function (err) {
if (err) {
throw err;
}
server.start();
});Options may also be set on a per-route basis:
var Hapi = require('hapi');
var Blankie = require('blankie');
var Scooter = require('scooter');
var server = new Hapi.Server();
server.route({
method: 'GET',
path: '/something',
config: {
handler: function (request, reply) {
reply('these settings are changed');
},
plugins: {
blankie: {
scriptSrc: 'self'
}
}
}
});Note that this setting will NOT be merged with your server-wide settings.
You may also set config.plugins.blankie equal to false on a route to disable CSP headers completely for that route.
Options
childSrc: Values forchild-srcdirective.connectSrc: Values for theconnect-srcdirective. Defaults'self'.defaultSrc: Values for thedefault-srcdirective. Defaults to'none'.fontSrc: Values for thefont-srcdirective.formAction: Values for theform-actiondirective.frameAncestors: Values for theframe-ancestorsdirective.frameSrc: Values for theframe-srcdirective.imgSrc: Values for theimage-srcdirective. Defaults to'self'.manifestSrc: Values for themanifest-srcdirective.mediaSrc: Values for themedia-srcdirective.objectSrc: Values for theobject-srcdirective.oldSafari: Force enabling buggy CSP for Safari 5.pluginTypes: Values for theplugin-typesdirective.reflectedXss: Value for thereflected-xssdirective. Must be one of'allow','block'or'filter'.reportOnly: Append '-Report-Only' to the name of the CSP header to enable report only mode.reportUri: Value for thereport-uridirective. This should be the path to a route that accepts CSP violation reports.sandbox: Values for thesandboxdirective. May be a boolean or one of'allow-forms','allow-same-origin','allow-scripts'or'allow-top-navigation'.scriptSrc: Values for thescript-srcdirective. Defaults to'self'.styleSrc: Values for thestyle-srcdirective. Defaults to'self'.