This repository has been archived by the owner on Aug 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding stronger password requirements for improving security based on…
… OWASP
- Loading branch information
Showing
20 changed files
with
300 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ describe('Article Model Unit Tests:', function () { | |
displayName: 'Full Name', | ||
email: '[email protected]', | ||
username: 'username', | ||
password: 'password' | ||
password: '[email protected]$Aw3$0m3' | ||
}); | ||
|
||
user.save(function () { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ describe('Article CRUD tests', function () { | |
// Create user credentials | ||
credentials = { | ||
username: 'username', | ||
password: 'password' | ||
password: '[email protected]$Aw3$0m3' | ||
}; | ||
|
||
// Create a new user | ||
|
5 changes: 3 additions & 2 deletions
5
modules/users/client/controllers/authentication.client.controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
modules/users/client/controllers/settings/change-password.client.controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
modules/users/client/directives/password-validator.client.directive.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use strict'; | ||
|
||
angular.module('users') | ||
.directive('passwordValidator', ['PasswordValidator', function(PasswordValidator) { | ||
return { | ||
require: 'ngModel', | ||
link: function(scope, element, attrs, modelCtrl) { | ||
modelCtrl.$parsers.unshift(function (password) { | ||
var result = PasswordValidator.getResult(password); | ||
var strengthIdx = 0; | ||
|
||
// Strength Meter - visual indicator for users | ||
var strengthMeter = [ | ||
{ color: "danger", progress: "20" }, | ||
{ color: "warning", progress: "40"}, | ||
{ color: "info", progress: "60"}, | ||
{ color: "primary", progress: "80"}, | ||
{ color: "success", progress: "100"} | ||
]; | ||
var strengthMax = strengthMeter.length; | ||
|
||
if (result.errors.length < strengthMeter.length) { | ||
strengthIdx = strengthMeter.length - result.errors.length - 1; | ||
} | ||
|
||
scope.strengthColor = strengthMeter[strengthIdx].color; | ||
scope.strengthProgress = strengthMeter[strengthIdx].progress; | ||
|
||
if (result.errors.length) { | ||
scope.popoverMsg = PasswordValidator.getPopoverMsg(); | ||
scope.passwordErrors = result.errors; | ||
modelCtrl.$setValidity('strength', false); | ||
return undefined; | ||
} else { | ||
scope.popoverMsg = ''; | ||
modelCtrl.$setValidity('strength', true); | ||
return password; | ||
} | ||
}); | ||
} | ||
}; | ||
}]); |
33 changes: 33 additions & 0 deletions
33
modules/users/client/directives/password-verify.client.directive.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
'use strict'; | ||
|
||
angular.module('users') | ||
.directive("passwordVerify", function() { | ||
return { | ||
require: "ngModel", | ||
scope: { | ||
passwordVerify: '=' | ||
}, | ||
link: function(scope, element, attrs, modelCtrl) { | ||
scope.$watch(function() { | ||
var combined; | ||
if (scope.passwordVerify || modelCtrl.$viewValue) { | ||
combined = scope.passwordVerify + '_' + modelCtrl.$viewValue; | ||
} | ||
return combined; | ||
}, function(value) { | ||
if (value) { | ||
modelCtrl.$parsers.unshift(function(viewValue) { | ||
var origin = scope.passwordVerify; | ||
if (origin !== viewValue) { | ||
modelCtrl.$setValidity("passwordVerify", false); | ||
return undefined; | ||
} else { | ||
modelCtrl.$setValidity("passwordVerify", true); | ||
return viewValue; | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
}; | ||
}); |
19 changes: 19 additions & 0 deletions
19
modules/users/client/services/password-validator.client.service.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
|
||
// PasswordValidator service used for testing the password strength | ||
angular.module('users').factory('PasswordValidator', ['$window', | ||
function ($window) { | ||
var owaspPasswordStrengthTest = $window.owaspPasswordStrengthTest; | ||
|
||
return { | ||
getResult: function (password) { | ||
var result = owaspPasswordStrengthTest.test(password); | ||
return result; | ||
}, | ||
getPopoverMsg: function () { | ||
var popoverMsg = "Please enter a passphrase or password with greater than 10 characters, numbers, lowercase, upppercase, and special characters."; | ||
return popoverMsg; | ||
} | ||
}; | ||
} | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 23 additions & 9 deletions
32
modules/users/client/views/password/reset-password.client.view.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.