Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

[feat] Added Lusca middleware for CSRF [fixes #828] #997

Merged
merged 1 commit into from
Feb 20, 2016
Merged
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
13 changes: 13 additions & 0 deletions config/env/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ module.exports = {
// for obsecurity reasons
sessionKey: 'sessionId',
sessionCollection: 'sessions',
// Lusca config
csrf: {
csrf: false,
csp: { /* Content Security Policy object */},
xframe: 'SAMEORIGIN',
p3p: 'ABCDEF',
hsts: {
maxAge: 31536000, // Forces HTTPS for one year
includeSubDomains: true,
preload: true
},
xssProtection: true
},
logo: 'modules/core/client/img/brand/logo.png',
favicon: 'modules/core/client/img/brand/favicon.ico',
uploads: {
Expand Down
8 changes: 6 additions & 2 deletions config/lib/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ var config = require('../config'),
helmet = require('helmet'),
flash = require('connect-flash'),
consolidate = require('consolidate'),
path = require('path');
path = require('path'),
lusca = require('lusca');

/**
* Initialize local variables
Expand Down Expand Up @@ -122,6 +123,9 @@ module.exports.initSession = function (app, db) {
collection: config.sessionCollection
})
}));

// Add Lusca CSRF Middleware
app.use(lusca(config.csrf));
};

/**
Expand Down Expand Up @@ -228,7 +232,7 @@ module.exports.init = function (db) {

// Initialize Express view engine
this.initViewEngine(app);

// Initialize Helmet security headers
this.initHelmetHeaders(app);

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"helmet": "~0.9.1",
"jasmine-core": "~2.3.4",
"lodash": "~3.10.0",
"lusca": "~1.3.0",
"method-override": "~2.3.3",
"mocha": "~2.4.5",
"mongoose": "~4.2.3",
Expand Down