Enforce passphrase policy (#490)

* Update jslib and initial commit for passphrase policy

* Removed unused strings

* Pulling in latest jslib (44b86f5 -> 36241e9)

* Made revision requests

Co-authored-by: Vincent Salucci <vsalucci@bitwarden.com>
This commit is contained in:
Vincent Salucci 2020-03-11 10:35:12 -05:00 committed by GitHub
parent 84dde72990
commit d255f6add4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 59 additions and 4 deletions

2
jslib

@ -1 +1 @@
Subproject commit 44b86f5dd028271059b70a00d7878fbb1a06023f
Subproject commit 36241e9eac029cfc3275e2a1d642ad5b0dfe8110

View File

@ -61,6 +61,16 @@
</div>
</ng-container>
<ng-container *ngIf="type === policyType.PasswordGenerator">
<div class="row">
<div class="col-6 form-group mb-0">
<label for="passGenDefaultType">{{'defaultType' | i18n}}</label>
<select id="passGenDefaultType" name="PassGenDefaultType" [(ngModel)]="passGenDefaultType"
class="form-control">
<option *ngFor="let o of defaultTypes" [ngValue]="o.value">{{o.name}}</option>
</select>
</div>
</div>
<h3 class="mt-4">{{'password' | i18n}}</h3>
<div class="row">
<div class="col-6 form-group">
<label for="passGenMinLength">{{'minLength' | i18n}}</label>
@ -100,6 +110,24 @@
[(ngModel)]="passGenUseSpecial" name="PassGenUseSpecial">
<label class="form-check-label" for="passGenUseSpecial">!@#$%^&amp;*</label>
</div>
<h3 class="mt-4">{{'passphrase' | i18n}}</h3>
<div class="row">
<div class="col-6 form-group">
<label for="passGenMinNumberWords">{{'minimumNumberOfWords' | i18n}}</label>
<input id="passGenMinNumberWords" class="form-control" type="number"
name="PassGenMinNumberWords" min="3" max="20" [(ngModel)]="passGenMinNumberWords">
</div>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="passGenCapitalize"
[(ngModel)]="passGenCapitalize" name="PassGenCapitalize">
<label class="form-check-label" for="passGenCapitalize">{{'capitalize' | i18n}}</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="passGenIncludeNumber"
[(ngModel)]="passGenIncludeNumber" name="PassGenIncludeNumber">
<label class="form-check-label" for="passGenIncludeNumber">{{'includeNumber' | i18n}}</label>
</div>
</ng-container>
</div>
<div class="modal-footer">

View File

@ -34,6 +34,7 @@ export class PolicyEditComponent implements OnInit {
enabled = false;
formPromise: Promise<any>;
passwordScores: any[];
defaultTypes: any[];
// Master password
@ -46,6 +47,7 @@ export class PolicyEditComponent implements OnInit {
// Password generator
passGenDefaultType?: string;
passGenMinLength?: number;
passGenUseUpper?: boolean;
passGenUseLower?: boolean;
@ -53,6 +55,9 @@ export class PolicyEditComponent implements OnInit {
passGenUseSpecial?: boolean;
passGenMinNumbers?: number;
passGenMinSpecial?: number;
passGenMinNumberWords?: number;
passGenCapitalize?: boolean;
passGenIncludeNumber?: boolean;
private policy: PolicyResponse;
@ -66,6 +71,11 @@ export class PolicyEditComponent implements OnInit {
{ name: i18nService.t('good') + ' (3)', value: 3 },
{ name: i18nService.t('strong') + ' (4)', value: 4 },
];
this.defaultTypes = [
{ name: i18nService.t('userPreference'), value: null },
{ name: i18nService.t('password'), value: 'password' },
{ name: i18nService.t('passphrase'), value: 'passphrase' },
];
}
async ngOnInit() {
@ -82,6 +92,7 @@ export class PolicyEditComponent implements OnInit {
if (this.policy.data != null) {
switch (this.type) {
case PolicyType.PasswordGenerator:
this.passGenDefaultType = this.policy.data.defaultType;
this.passGenMinLength = this.policy.data.minLength;
this.passGenUseUpper = this.policy.data.useUpper;
this.passGenUseLower = this.policy.data.useLower;
@ -89,6 +100,9 @@ export class PolicyEditComponent implements OnInit {
this.passGenUseSpecial = this.policy.data.useSpecial;
this.passGenMinNumbers = this.policy.data.minNumbers;
this.passGenMinSpecial = this.policy.data.minSpecial;
this.passGenMinNumberWords = this.policy.data.minNumberWords;
this.passGenCapitalize = this.policy.data.capitalize;
this.passGenIncludeNumber = this.policy.data.includeNumber;
break;
case PolicyType.MasterPassword:
this.masterPassMinComplexity = this.policy.data.minComplexity;
@ -120,6 +134,7 @@ export class PolicyEditComponent implements OnInit {
switch (this.type) {
case PolicyType.PasswordGenerator:
request.data = {
defaultType: this.passGenDefaultType,
minLength: this.passGenMinLength || null,
useUpper: this.passGenUseUpper,
useLower: this.passGenUseLower,
@ -127,6 +142,9 @@ export class PolicyEditComponent implements OnInit {
useSpecial: this.passGenUseSpecial,
minNumbers: this.passGenMinNumbers || null,
minSpecial: this.passGenMinSpecial || null,
minNumberWords: this.passGenMinNumberWords || null,
capitalize: this.passGenCapitalize,
includeNumber: this.passGenIncludeNumber,
};
break;
case PolicyType.MasterPassword:

View File

@ -1,7 +1,7 @@
<div class="page-header">
<h1>{{'passwordGenerator' | i18n}}</h1>
</div>
<app-callout type="info" *ngIf="policyInEffect">
<app-callout type="info" *ngIf="enforcedPolicyOptions?.inEffect()">
{{'passwordGeneratorPolicyInEffect' | i18n}}
</app-callout>
<div class="card card-password bg-light my-4">
@ -37,12 +37,12 @@
<div class="form-group">
<div class="form-check">
<input id="capitalize" class="form-check-input" type="checkbox" (change)="saveOptions()"
[(ngModel)]="options.capitalize">
[(ngModel)]="options.capitalize" [disabled]="enforcedPolicyOptions?.capitalize">
<label for="capitalize" class="form-check-label">{{'capitalize' | i18n}}</label>
</div>
<div class="form-check">
<input id="include-number" class="form-check-input" type="checkbox" (change)="saveOptions()"
[(ngModel)]="options.includeNumber">
[(ngModel)]="options.includeNumber" [disabled]="enforcedPolicyOptions?.includeNumber">
<label for="include-number" class="form-check-label">{{'includeNumber' | i18n}}</label>
</div>
</div>

View File

@ -3031,5 +3031,14 @@
},
"masterPasswordPolicyRequirementsNotMet": {
"message": "Your new master password does not meet the policy requirements."
},
"minimumNumberOfWords": {
"message": "Minimum Number of Words"
},
"defaultType": {
"message": "Default Type"
},
"userPreference": {
"message": "User Preference"
}
}