2015-08-04 01:25:34 -07:00
|
|
|
import helmet from 'helmet';
|
|
|
|
|
|
|
|
const trusted = [
|
2015-12-07 15:30:54 -08:00
|
|
|
"'self'"
|
2015-08-04 01:25:34 -07:00
|
|
|
];
|
|
|
|
|
|
|
|
export default function csp() {
|
|
|
|
return helmet.csp({
|
|
|
|
defaultSrc: trusted,
|
|
|
|
scriptSrc: [
|
2015-12-07 15:30:54 -08:00
|
|
|
"'unsafe-eval'",
|
|
|
|
"'unsafe-inline'",
|
|
|
|
'*.google-analytics.com',
|
|
|
|
'*.gstatic.com',
|
|
|
|
'https://*.cloudflare.com',
|
|
|
|
'*.cloudflare.com',
|
2015-10-08 16:42:24 -07:00
|
|
|
'https://*.gitter.im',
|
2015-12-07 15:30:54 -08:00
|
|
|
'https://*.cdnjs.com',
|
|
|
|
'*.cdnjs.com',
|
|
|
|
'https://*.jsdelivr.com',
|
|
|
|
'*.jsdelivr.com',
|
|
|
|
'*.twimg.com',
|
|
|
|
'https://*.twimg.com'
|
2015-08-04 01:25:34 -07:00
|
|
|
].concat(trusted),
|
2015-12-09 11:02:06 -08:00
|
|
|
connectSrc: [
|
2015-08-04 01:25:34 -07:00
|
|
|
'vimeo.com'
|
|
|
|
].concat(trusted),
|
|
|
|
styleSrc: [
|
2015-12-07 15:30:54 -08:00
|
|
|
"'unsafe-inline'",
|
|
|
|
'*.gstatic.com',
|
2015-08-04 01:25:34 -07:00
|
|
|
'*.googleapis.com',
|
2015-12-07 15:30:54 -08:00
|
|
|
'*.bootstrapcdn.com',
|
|
|
|
'https://*.bootstrapcdn.com',
|
|
|
|
'*.cloudflare.com',
|
|
|
|
'https://*.cloudflare.com'
|
|
|
|
].concat(trusted),
|
|
|
|
fontSrc: [
|
|
|
|
'*.cloudflare.com',
|
|
|
|
'https://*.cloudflare.com',
|
|
|
|
'*.bootstrapcdn.com',
|
|
|
|
'*.googleapis.com',
|
|
|
|
'*.gstatic.com',
|
|
|
|
'https://*.bootstrapcdn.com'
|
2015-08-04 01:25:34 -07:00
|
|
|
].concat(trusted),
|
|
|
|
imgSrc: [
|
|
|
|
// allow all input since we have user submitted images for
|
|
|
|
// public profile
|
2015-10-16 20:23:24 -07:00
|
|
|
'*',
|
|
|
|
'data:'
|
2015-12-07 15:30:54 -08:00
|
|
|
],
|
2015-08-04 01:25:34 -07:00
|
|
|
mediaSrc: [
|
2015-12-07 15:30:54 -08:00
|
|
|
'*.bitly.com',
|
2015-08-04 01:25:34 -07:00
|
|
|
'*.amazonaws.com',
|
|
|
|
'*.twitter.com'
|
|
|
|
].concat(trusted),
|
|
|
|
frameSrc: [
|
|
|
|
'*.gitter.im',
|
|
|
|
'*.gitter.im https:',
|
|
|
|
'*.vimeo.com',
|
|
|
|
'*.twitter.com',
|
2015-12-09 11:02:06 -08:00
|
|
|
'*.ghbtns.com',
|
|
|
|
'*.freecatphotoapp.com'
|
2015-08-04 01:25:34 -07:00
|
|
|
].concat(trusted),
|
|
|
|
// set to true if you only want to report errors
|
|
|
|
reportOnly: false,
|
|
|
|
// set to true if you want to set all headers
|
|
|
|
setAllHeaders: false,
|
|
|
|
// set to true if you want to force buggy CSP in Safari 5
|
|
|
|
safari5: false
|
|
|
|
});
|
|
|
|
}
|