feat(angular): added owasp configuration for frontend

Added configuration for owasp. Synchronize client owap configs with t…
This commit is contained in:
Liran Tal
2016-09-13 00:19:41 +03:00
committed by GitHub
6 changed files with 28 additions and 5 deletions

10
config/env/default.js vendored
View File

@@ -46,5 +46,15 @@ module.exports = {
fileSize: 1 * 1024 * 1024 // Max file size in bytes (1 MB)
}
}
},
shared: {
owasp: {
allowPassphrases: true,
maxLength: 128,
minLength: 10,
minPhraseLength: 20,
minOptionalTestsToPass: 4
}
}
};

View File

@@ -1,12 +1,13 @@
'use strict';
var validator = require('validator');
var validator = require('validator'),
path = require('path'),
config = require(path.resolve('./config/config'));
/**
* Render the main application page
*/
exports.renderIndex = function (req, res) {
var safeUserObject = null;
if (req.user) {
safeUserObject = {
@@ -24,7 +25,8 @@ exports.renderIndex = function (req, res) {
}
res.render('modules/core/server/views/index', {
user: JSON.stringify(safeUserObject)
user: JSON.stringify(safeUserObject),
sharedConfig: JSON.stringify(config.shared)
});
};

View File

@@ -65,6 +65,12 @@
<!--Application JavaScript Files-->
{{#each jsFiles}}<script type="text/javascript" src="{{this}}"></script>{{/each}}
<!--owasp config sync-->
<script type="text/javascript">
var sharedConfig = {{{ sharedConfig }}};
owaspPasswordStrengthTest.config(sharedConfig.owasp);
</script>
{{#if livereload}}
<!--Livereload script rendered -->

View File

@@ -24,7 +24,7 @@
}
function getPopoverMsg() {
var popoverMsg = 'Please enter a passphrase or password with 10 or more characters, numbers, lowercase, uppercase, and special characters.';
var popoverMsg = 'Please enter a passphrase or password with ' + owaspPasswordStrengthTest.configs.minLength + ' or more characters, numbers, lowercase, uppercase, and special characters.';
return popoverMsg;
}

View File

@@ -22,7 +22,7 @@ module.exports = function () {
}
if (!user || !user.authenticate(password)) {
return done(null, false, {
message: 'Invalid username or password'
message: 'Invalid username or password (' + (new Date()).toLocaleTimeString() + ')'
});
}

View File

@@ -4,12 +4,17 @@
* Module dependencies
*/
var mongoose = require('mongoose'),
path = require('path'),
config = require(path.resolve('./config/config')),
Schema = mongoose.Schema,
crypto = require('crypto'),
validator = require('validator'),
generatePassword = require('generate-password'),
owasp = require('owasp-password-strength-test');
owasp.config(config.shared.owasp);
/**
* A Validation function for local strategy properties
*/