mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 08:43:33 +00:00
Password Generator Passphrase Policy (#85)
* Initial commit for passphrase enforcement * Updated type implementation * Updated default type conditional * Added helper method to enforced options object Co-authored-by: Vincent Salucci <vsalucci@bitwarden.com>
This commit is contained in:
@@ -19,7 +19,6 @@ export class PasswordGeneratorComponent implements OnInit {
|
||||
password: string = '-';
|
||||
showOptions = false;
|
||||
avoidAmbiguous = false;
|
||||
policyInEffect = false;
|
||||
enforcedPolicyOptions: PasswordGeneratorPolicyOptions;
|
||||
|
||||
constructor(protected passwordGenerationService: PasswordGenerationService,
|
||||
@@ -30,14 +29,6 @@ export class PasswordGeneratorComponent implements OnInit {
|
||||
const optionsResponse = await this.passwordGenerationService.getOptions();
|
||||
this.options = optionsResponse[0];
|
||||
this.enforcedPolicyOptions = optionsResponse[1];
|
||||
this.policyInEffect = this.enforcedPolicyOptions != null && (
|
||||
this.enforcedPolicyOptions.minLength > 0 ||
|
||||
this.enforcedPolicyOptions.numberCount > 0 ||
|
||||
this.enforcedPolicyOptions.specialCount > 0 ||
|
||||
this.enforcedPolicyOptions.useUppercase ||
|
||||
this.enforcedPolicyOptions.useLowercase ||
|
||||
this.enforcedPolicyOptions.useNumbers ||
|
||||
this.enforcedPolicyOptions.useSpecial);
|
||||
this.avoidAmbiguous = !this.options.ambiguous;
|
||||
this.options.type = this.options.type === 'passphrase' ? 'passphrase' : 'password';
|
||||
this.password = await this.passwordGenerationService.generatePassword(this.options);
|
||||
@@ -147,6 +138,10 @@ export class PasswordGeneratorComponent implements OnInit {
|
||||
this.options.numWords = 20;
|
||||
}
|
||||
|
||||
if (this.options.numWords < this.enforcedPolicyOptions.minNumberWords) {
|
||||
this.options.numWords = this.enforcedPolicyOptions.minNumberWords;
|
||||
}
|
||||
|
||||
if (this.options.wordSeparator != null && this.options.wordSeparator.length > 1) {
|
||||
this.options.wordSeparator = this.options.wordSeparator[0];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user