Enforce Password Generator Policy Options (#469)

* Initial commit for enforcing password generator policy options

* Revert to previous isDev URL setup
This commit is contained in:
Vincent Salucci 2020-02-26 18:32:57 -06:00 committed by GitHub
parent 5ed830205d
commit a27eddae56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 13 deletions

View File

@ -59,19 +59,19 @@
<div class="col-6 form-group">
<label for="passGenMinLength">{{'minLength' | i18n}}</label>
<input id="passGenMinLength" class="form-control" type="number" name="PassGenMinLength"
[(ngModel)]="passGenMinLength">
min="5" max="128" [(ngModel)]="passGenMinLength">
</div>
</div>
<div class="row">
<div class="col-6 form-group">
<label for="passGenMinNumbers">{{'minNumbers' | i18n}}</label>
<input id="passGenMinNumbers" class="form-control" type="number" name="PassGenMinNumbers"
[(ngModel)]="passGenMinNumbers">
min="0" max="9" [(ngModel)]="passGenMinNumbers">
</div>
<div class="col-6 form-group">
<label for="passGenMinSpecial">{{'minSpecial' | i18n}}</label>
<input id="passGenMinSpecial" class="form-control" type="number" name="PassGenMinSpecial"
[(ngModel)]="passGenMinSpecial">
min="0" max="9" [(ngModel)]="passGenMinSpecial">
</div>
</div>
<div class="form-check">

View File

@ -113,7 +113,7 @@ const lockService = new LockService(cipherService, folderService, collectionServ
const syncService = new SyncService(userService, apiService, settingsService,
folderService, cipherService, cryptoService, collectionService, storageService, messagingService, policyService,
async (expired: boolean) => messagingService.send('logout', { expired: expired }));
const passwordGenerationService = new PasswordGenerationService(cryptoService, storageService);
const passwordGenerationService = new PasswordGenerationService(cryptoService, storageService, policyService);
const totpService = new TotpService(storageService, cryptoFunctionService);
const containerService = new ContainerService(cryptoService);
const authService = new AuthService(cryptoService, apiService,

View File

@ -53,34 +53,34 @@
</div>
<div class="form-group col-4">
<label for="min-number">{{'minNumbers' | i18n}}</label>
<input id="min-number" class="form-control" type="number" min="0" max="9" (input)="saveOptions()"
[(ngModel)]="options.minNumber">
<input id="min-number" class="form-control" type="number" min="0" max="9" (blur)="saveOptions()"
[(ngModel)]="options.minNumber" (change)="minNumberChanged()">
</div>
<div class="form-group col-4">
<label for="min-special">{{'minSpecial' | i18n}}</label>
<input id="min-special" class="form-control" type="number" min="0" max="9" (input)="saveOptions()"
[(ngModel)]="options.minSpecial">
<input id="min-special" class="form-control" type="number" min="0" max="9" (blur)="saveOptions()"
[(ngModel)]="options.minSpecial" (change)="minSpecialChanged()">
</div>
</div>
<div class="form-group">
<div class="form-check">
<input id="uppercase" class="form-check-input" type="checkbox" (change)="saveOptions()"
[(ngModel)]="options.uppercase">
[(ngModel)]="options.uppercase" [disabled]="enforcedPolicyOptions?.useUppercase">
<label for="uppercase" class="form-check-label">A-Z</label>
</div>
<div class="form-check">
<input id="lowercase" class="form-check-input" type="checkbox" (change)="saveOptions()"
[(ngModel)]="options.lowercase">
[(ngModel)]="options.lowercase" [disabled]="enforcedPolicyOptions?.useLowercase">
<label for="lowercase" class="form-check-label">a-z</label>
</div>
<div class="form-check">
<input id="numbers" class="form-check-input" type="checkbox" (change)="saveOptions()"
[(ngModel)]="options.number">
[(ngModel)]="options.number" [disabled]="enforcedPolicyOptions?.useNumbers">
<label for="numbers" class="form-check-label">0-9</label>
</div>
<div class="form-check">
<input id="special" class="form-check-input" type="checkbox" (change)="saveOptions()"
[(ngModel)]="options.special">
[(ngModel)]="options.special" [disabled]="enforcedPolicyOptions?.useSpecial">
<label for="special" class="form-check-label">!@#$%^&amp;*</label>
</div>
<div class="form-check">

View File

@ -47,4 +47,12 @@ export class PasswordGeneratorComponent extends BasePasswordGeneratorComponent {
lengthChanged() {
document.getElementById('length').focus();
}
minNumberChanged() {
document.getElementById('min-number').focus();
}
minSpecialChanged() {
document.getElementById('min-special').focus();
}
}

View File

@ -103,7 +103,7 @@ export class AddEditComponent extends BaseAddEditComponent {
async generatePassword(): Promise<boolean> {
const confirmed = await super.generatePassword();
if (confirmed) {
const options = await this.passwordGenerationService.getOptions();
const options = (await this.passwordGenerationService.getOptions())[0];
this.cipher.login.password = await this.passwordGenerationService.generatePassword(options);
}
return confirmed;