From ef602ff6a47fa09f20869f2433710ab52787b4b9 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 3 Mar 2020 16:29:10 -0500 Subject: [PATCH] enforce policies on generate command (#115) --- jslib | 2 +- src/bw.ts | 3 ++- src/commands/generate.command.ts | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/jslib b/jslib index 3d2e2cb174..44b86f5dd0 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 3d2e2cb1741be8b7b2916574f62f7ba2193c7123 +Subproject commit 44b86f5dd028271059b70a00d7878fbb1a06023f diff --git a/src/bw.ts b/src/bw.ts index e440ccd267..178294bec6 100644 --- a/src/bw.ts +++ b/src/bw.ts @@ -119,7 +119,8 @@ export class Main { this.folderService, this.cipherService, this.cryptoService, this.collectionService, this.storageService, this.messagingService, this.policyService, async (expired: boolean) => await this.logout()); - this.passwordGenerationService = new PasswordGenerationService(this.cryptoService, this.storageService); + this.passwordGenerationService = new PasswordGenerationService(this.cryptoService, this.storageService, + this.policyService); this.totpService = new TotpService(this.storageService, this.cryptoFunctionService); this.importService = new ImportService(this.cipherService, this.folderService, this.apiService, this.i18nService, this.collectionService); diff --git a/src/commands/generate.command.ts b/src/commands/generate.command.ts index 18dc64866a..79a3c3a4aa 100644 --- a/src/commands/generate.command.ts +++ b/src/commands/generate.command.ts @@ -35,7 +35,8 @@ export class GenerateCommand { } else if (options.wordSeparator != null && options.wordSeparator.length > 1) { options.wordSeparator = options.wordSeparator[0]; } - const password = await this.passwordGenerationService.generatePassword(options); + const enforcedOptions = await this.passwordGenerationService.enforcePasswordGeneratorPoliciesOnOptions(options); + const password = await this.passwordGenerationService.generatePassword(enforcedOptions[0]); const res = new StringResponse(password); return Response.success(res); }