1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 16:53:34 +00:00

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
5 changed files with 59 additions and 4 deletions

2
jslib

Submodule jslib updated: 44b86f5dd0...36241e9eac

View File

@@ -61,6 +61,16 @@
</div> </div>
</ng-container> </ng-container>
<ng-container *ngIf="type === policyType.PasswordGenerator"> <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="row">
<div class="col-6 form-group"> <div class="col-6 form-group">
<label for="passGenMinLength">{{'minLength' | i18n}}</label> <label for="passGenMinLength">{{'minLength' | i18n}}</label>
@@ -100,6 +110,24 @@
[(ngModel)]="passGenUseSpecial" name="PassGenUseSpecial"> [(ngModel)]="passGenUseSpecial" name="PassGenUseSpecial">
<label class="form-check-label" for="passGenUseSpecial">!@#$%^&amp;*</label> <label class="form-check-label" for="passGenUseSpecial">!@#$%^&amp;*</label>
</div> </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> </ng-container>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">

View File

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

View File

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

View File

@@ -3031,5 +3031,14 @@
}, },
"masterPasswordPolicyRequirementsNotMet": { "masterPasswordPolicyRequirementsNotMet": {
"message": "Your new master password does not meet the policy requirements." "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"
} }
} }