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

Commit d896d07

Browse files
committed
Added configuration for owasp. Synchronize client owap configs with the server configs.
Also added a time indicator on failed login attempts to give the user feedback on subsequent failed login attempts.
1 parent dd80951 commit d896d07

File tree

7 files changed

+42
-4
lines changed

7 files changed

+42
-4
lines changed

config/env/development.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ module.exports = {
5858
callbackURL: '/api/auth/paypal/callback',
5959
sandbox: true
6060
},
61+
owasp: {
62+
allowPassphrases: true,
63+
maxLength: 128,
64+
minLength: 4,
65+
minPhraseLength: 20,
66+
minOptionalTestsToPass: 2
67+
},
6168
mailer: {
6269
from: process.env.MAILER_FROM || 'MAILER_FROM',
6370
options: {

config/env/production.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ module.exports = {
7878
callbackURL: '/api/auth/paypal/callback',
7979
sandbox: false
8080
},
81+
owasp: {
82+
allowPassphrases : true,
83+
maxLength : 128,
84+
minLength : 10,
85+
minPhraseLength : 20,
86+
minOptionalTestsToPass : 4,
87+
},
8188
mailer: {
8289
from: process.env.MAILER_FROM || 'MAILER_FROM',
8390
options: {

modules/users/client/services/password-validator.client.service.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,18 @@
66
.module('users.services')
77
.factory('PasswordValidator', PasswordValidator);
88

9-
PasswordValidator.$inject = ['$window'];
9+
PasswordValidator.$inject = ['$window', '$http'];
1010

11-
function PasswordValidator($window) {
11+
function PasswordValidator($window, $http) {
1212
var owaspPasswordStrengthTest = $window.owaspPasswordStrengthTest;
1313

14+
// get the owasp config from the server configuration
15+
$http.get('/password/rules').success(function (response) {
16+
owaspPasswordStrengthTest.configs = response; // same owasp config used on the server
17+
}).error(function (response) {
18+
// well, it should fall back on the default owasp config defined in that package
19+
});
20+
1421
var service = {
1522
getResult: getResult,
1623
getPopoverMsg: getPopoverMsg
@@ -24,7 +31,7 @@
2431
}
2532

2633
function getPopoverMsg() {
27-
var popoverMsg = 'Please enter a passphrase or password with 10 or more characters, numbers, lowercase, uppercase, and special characters.';
34+
var popoverMsg = 'Please enter a passphrase or password with ' + owaspPasswordStrengthTest.configs.minLength + ' or more characters, numbers, lowercase, uppercase, and special characters.';
2835

2936
return popoverMsg;
3037
}

modules/users/server/config/strategies/local.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = function () {
2222
}
2323
if (!user || !user.authenticate(password)) {
2424
return done(null, false, {
25-
message: 'Invalid username or password'
25+
message: 'Invalid username or password (' + (new Date()).toLocaleTimeString() + ')'
2626
});
2727
}
2828

modules/users/server/controllers/users/users.password.server.controller.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ var path = require('path'),
1414

1515
var smtpTransport = nodemailer.createTransport(config.mailer.options);
1616

17+
/**
18+
* Get the server defined owasp config for the client
19+
*/
20+
exports.getowaspconfig = function (req, res) {
21+
res.json(config.owasp);
22+
};
23+
1724
/**
1825
* Forgot for reset password (forgot POST)
1926
*/

modules/users/server/models/user.server.model.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@
44
* Module dependencies
55
*/
66
var mongoose = require('mongoose'),
7+
path = require('path'),
8+
config = require(path.resolve('./config/config')),
79
Schema = mongoose.Schema,
810
crypto = require('crypto'),
911
validator = require('validator'),
1012
generatePassword = require('generate-password'),
1113
owasp = require('owasp-password-strength-test');
1214

15+
16+
owasp.configs = config.owasp;
17+
18+
1319
/**
1420
* A Validation function for local strategy properties
1521
*/

modules/users/server/routes/auth.server.routes.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,8 @@ module.exports = function (app) {
5454
// Setting the paypal oauth routes
5555
app.route('/api/auth/paypal').get(users.oauthCall('paypal'));
5656
app.route('/api/auth/paypal/callback').get(users.oauthCallback('paypal'));
57+
58+
59+
// get the config settings for the client side owasp
60+
app.route('/password/rules').get(users.getowaspconfig);
5761
};

0 commit comments

Comments
 (0)