Skip to content

Commit

Permalink
chore(csp): add CSP meta tag and nonce for styles (elastic#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
markov00 authored Apr 11, 2019
1 parent ad591c3 commit 56d67aa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<meta
http-equiv="Content-Security-Policy"
content="default-src 'self'; style-src 'nonce-Pk1rZ1XDlMuYe8ubWV3Lh0BzwrTigJQ='"
/>
5 changes: 3 additions & 2 deletions .storybook/theme_service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* tslint:disable */
// @ts-ignore
import themeDark from '!!style-loader/useable!css-loader!@elastic/eui/dist/eui_theme_dark.css';
import themeDark from '!!style-loader/useable?{attrs:{"nonce":"Pk1rZ1XDlMuYe8ubWV3Lh0BzwrTigJQ="}}!css-loader!@elastic/eui/dist/eui_theme_dark.css';
// @ts-ignore
import themeLight from '!!style-loader/useable!css-loader!@elastic/eui/dist/eui_theme_light.css';
import themeLight from '!!style-loader/useable?{attrs:{"nonce":"Pk1rZ1XDlMuYe8ubWV3Lh0BzwrTigJQ="}}!css-loader!@elastic/eui/dist/eui_theme_light.css';

export function switchTheme(theme: string) {
switch (theme) {
Expand Down
5 changes: 5 additions & 0 deletions .storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ module.exports = (baseConfig, env, config) => {
use: [
{
loader: 'style-loader',
options: {
attrs: {
nonce: 'Pk1rZ1XDlMuYe8ubWV3Lh0BzwrTigJQ=',
},
},
},
{
loader: 'css-loader',
Expand Down

0 comments on commit 56d67aa

Please sign in to comment.