Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Configurable browser policy #62

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions demo/server/helmetConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import helmet from 'helmet';


// See for https://github.com/helmetjs/helmet for details of configuration
const helmetConfig = helmet({
contentSecurityPolicy: {
directives: {
defaultSrc: ["'none'"],
imgSrc: ["'self'"],
scriptSrc: ["'self'", "'unsafe-inline'", "'unsafe-eval'"],
styleSrc: ["'self'", "'unsafe-inline'" ],
connectSrc : ["'self'", 'ws:'],
}
}
});

export default helmetConfig;
4 changes: 4 additions & 0 deletions demo/server/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import PubSub from '/imports/api/PubSub';
import '/imports/api/PubSub/server';
// Store subscription
import storeSubscription from '/imports/store';
//helmet config
import helmetConfig from './helmetConfig';
// i18n
// eslint-disable-next-line no-unused-vars
import i18n from '/imports/i18n/i18nServer';
Expand All @@ -37,6 +39,8 @@ logger.info('Starting router');
createRouter({
// Your MainApp as the top component rendered and injected in the HTML payload
MainApp,
// Optional: Helmet config
helmetConfig,
// Optional: Store subscription
storeSubscription,
// Optional: An object containing your application reducers
Expand Down
3 changes: 3 additions & 0 deletions src/server/createRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const EXPRESS_COVERED_URL = /^\/(?!api\/)(?!__cordova\/)[^.]*$/;
/* eslint-disable no-param-reassign */
const createRouter = ({
MainApp,
helmetConfig,
storeSubscription,
appReducers = {},
appCursors = {},
Expand All @@ -56,6 +57,8 @@ const createRouter = ({
const app = express();
// Secure Express
app.use(helmet());
// modify express if supplied
if (helmetConfig) app.use(helmetConfig);
// express middleware to handle i18n
if (i18n) app.use(i18nMiddleware.handle(i18n));
app
Expand Down