Skip to content

Commit

Permalink
Merge branch 'csp-fixes' into 'master'
Browse files Browse the repository at this point in the history
CSP fixes: allow inline scripts/styles, disable CSP on localhost

See merge request BigDataBoutique/elastiquill!17
  • Loading branch information
synhershko committed Apr 17, 2019
2 parents 8fe779e + 3c07b82 commit 2490793
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion backend/src/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@ router.use(asyncHandler(async (req, res, next) => {

res.locals.gaTrackingId = _.get(config, 'credentials.google.analytics-code', null);
res.locals.adminRoute = config.blog['admin-route'];
res.locals.isLocalhost = config.blog.url.startsWith('http://localhost');

res.locals.sidebarWidgetData = await cache.cacheAndReturn('sidebar-widget-data', async () => {
const { items, allTags } = await blogPosts.getItems({ type: 'post', pageIndex: 0, pageSize: 10 });
return {
recentPosts: items.map(preparePost),
allTags
};
});
});

next();
}));
Expand Down
4 changes: 3 additions & 1 deletion backend/src/views/base/layouts/main.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
<link rel="canonical" href="{{canonicalUrl}}" />
{{/if}}

<meta http-equiv="Content-Security-Policy" content="default-src https:">
{{#unless isLocalhost}}
<meta http-equiv="Content-Security-Policy" content="default-src https: 'unsafe-inline'">
{{/unless}}

<link rel="shortcut icon" href="/static/base/favicon/favicon.ico">
<link rel="apple-touch-icon" sizes="180x180" href="/static/base/favicon/apple-touch-icon.png">
Expand Down

0 comments on commit 2490793

Please sign in to comment.