mirror of
https://github.com/moparisthebest/mail
synced 2024-12-21 23:08:50 -05:00
[WO-03-018] Fix weak Passwords & Misleading Passphrase Strength Check (Low)
Remove unsafe password strength indicator
This commit is contained in:
parent
b687986980
commit
701eb36b19
@ -21,59 +21,6 @@ var SetPassphraseCtrl = function($scope, $q, pgp, keychain, dialog) {
|
|||||||
// scope functions
|
// scope functions
|
||||||
//
|
//
|
||||||
|
|
||||||
/*
|
|
||||||
* Taken from jQuery validate.password plug-in 1.0
|
|
||||||
* http://bassistance.de/jquery-plugins/jquery-plugin-validate.password/
|
|
||||||
*
|
|
||||||
* Copyright (c) 2009 Jörn Zaefferer
|
|
||||||
*
|
|
||||||
* Licensed under the MIT
|
|
||||||
* http://www.opensource.org/licenses/mit-license.php
|
|
||||||
*/
|
|
||||||
$scope.checkPassphraseQuality = function() {
|
|
||||||
var passphrase = $scope.newPassphrase;
|
|
||||||
$scope.passphraseRating = 0;
|
|
||||||
|
|
||||||
var LOWER = /[a-z]/,
|
|
||||||
UPPER = /[A-Z]/,
|
|
||||||
DIGIT = /[0-9]/,
|
|
||||||
DIGITS = /[0-9].*[0-9]/,
|
|
||||||
SPECIAL = /[^a-zA-Z0-9]/,
|
|
||||||
SAME = /^(.)\1+$/;
|
|
||||||
|
|
||||||
function uncapitalize(str) {
|
|
||||||
return str.substring(0, 1).toLowerCase() + str.substring(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!passphrase) {
|
|
||||||
// no rating for empty passphrase
|
|
||||||
$scope.passphraseMsg = '';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (passphrase.length < 8 || SAME.test(passphrase)) {
|
|
||||||
$scope.passphraseMsg = 'Very weak';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var lower = LOWER.test(passphrase),
|
|
||||||
upper = UPPER.test(uncapitalize(passphrase)),
|
|
||||||
digit = DIGIT.test(passphrase),
|
|
||||||
digits = DIGITS.test(passphrase),
|
|
||||||
special = SPECIAL.test(passphrase);
|
|
||||||
|
|
||||||
if (lower && upper && digit || lower && digits || upper && digits || special) {
|
|
||||||
$scope.passphraseMsg = 'Strong';
|
|
||||||
$scope.passphraseRating = 3;
|
|
||||||
} else if (lower && upper || lower && digit || upper && digit) {
|
|
||||||
$scope.passphraseMsg = 'Good';
|
|
||||||
$scope.passphraseRating = 2;
|
|
||||||
} else {
|
|
||||||
$scope.passphraseMsg = 'Weak';
|
|
||||||
$scope.passphraseRating = 1;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.setPassphrase = function() {
|
$scope.setPassphrase = function() {
|
||||||
var keyId = pgp.getKeyParams()._id;
|
var keyId = pgp.getKeyParams()._id;
|
||||||
|
|
||||||
|
@ -10,10 +10,6 @@
|
|||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
color: $color-error;
|
color: $color-error;
|
||||||
}
|
}
|
||||||
&__password-strong-message {
|
|
||||||
margin-bottom: 10px;
|
|
||||||
color: green;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__row {
|
&__row {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
|
@ -16,12 +16,11 @@
|
|||||||
<input class="input-text" type="password" ng-model="oldPassphrase" placeholder="Current passphrase" tabindex="1" wo-focus-me="true">
|
<input class="input-text" type="password" ng-model="oldPassphrase" placeholder="Current passphrase" tabindex="1" wo-focus-me="true">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="form__error-message" ng-show="passphraseMsg && passphraseRating < 2">{{passphraseMsg}}</p>
|
<p class="form__error-message" ng-show="passphraseMsg">{{passphraseMsg}}</p>
|
||||||
<p class="form__password-strong-message" ng-show="passphraseMsg && passphraseRating >= 2">{{passphraseMsg}}</p>
|
|
||||||
<div class="form__row form__row--multi">
|
<div class="form__row form__row--multi">
|
||||||
<div class="form__col">
|
<div class="form__col">
|
||||||
<input class="input-text" type="password" ng-model="newPassphrase"
|
<input class="input-text" type="password" ng-model="newPassphrase"
|
||||||
placeholder="New passphrase" ng-change="checkPassphraseQuality()" tabindex="2">
|
placeholder="New passphrase" tabindex="2">
|
||||||
</div>
|
</div>
|
||||||
<div class="form__col">
|
<div class="form__col">
|
||||||
<input class="input-text" type="password" ng-model="confirmation" placeholder="Confirm passphrase"
|
<input class="input-text" type="password" ng-model="confirmation" placeholder="Confirm passphrase"
|
||||||
|
@ -79,46 +79,4 @@ describe('Set Passphrase Controller unit test', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('check passphrase quality', function() {
|
|
||||||
it('should be too short', function() {
|
|
||||||
scope.newPassphrase = '&§DG36';
|
|
||||||
scope.checkPassphraseQuality();
|
|
||||||
|
|
||||||
expect(scope.passphraseMsg).to.equal('Very weak');
|
|
||||||
expect(scope.passphraseRating).to.equal(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be very weak', function() {
|
|
||||||
scope.newPassphrase = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
|
|
||||||
scope.checkPassphraseQuality();
|
|
||||||
|
|
||||||
expect(scope.passphraseMsg).to.equal('Very weak');
|
|
||||||
expect(scope.passphraseRating).to.equal(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be weak', function() {
|
|
||||||
scope.newPassphrase = 'asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf';
|
|
||||||
scope.checkPassphraseQuality();
|
|
||||||
|
|
||||||
expect(scope.passphraseMsg).to.equal('Weak');
|
|
||||||
expect(scope.passphraseRating).to.equal(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be good', function() {
|
|
||||||
scope.newPassphrase = 'asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf5';
|
|
||||||
scope.checkPassphraseQuality();
|
|
||||||
|
|
||||||
expect(scope.passphraseMsg).to.equal('Good');
|
|
||||||
expect(scope.passphraseRating).to.equal(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be strong', function() {
|
|
||||||
scope.newPassphrase = '&§DG36abcd';
|
|
||||||
scope.checkPassphraseQuality();
|
|
||||||
|
|
||||||
expect(scope.passphraseMsg).to.equal('Strong');
|
|
||||||
expect(scope.passphraseRating).to.equal(3);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
Loading…
Reference in New Issue
Block a user