From 50eea96ec5b8a9c9914fcead09ff4f3690b7c3b5 Mon Sep 17 00:00:00 2001 From: SmithThe4th Date: Thu, 4 May 2023 09:46:12 -0400 Subject: [PATCH] [PM-1699] Updated low kdf iterations warning (#5170) * updated low ksf iterations warning * Removed test implementation * Removed unused translation and updated key * Enabled low kdf on this branch for testing * Removed duplicate showKdf initialiazation * [PM-1700] Put KDF warning behind a LaunchDarkly Feature Flag (#5308) * Added feature flag for low kdf iteration * Added feature flag implementation to component * Renamed feature flag to align with what is setup on LaunchDarkly --- .../src/app/settings/low-kdf.component.html | 4 ++-- .../vault/individual-vault/vault.component.ts | 22 ++++++++++++++----- apps/web/src/locales/en/messages.json | 10 ++++----- libs/common/src/enums/feature-flag.enum.ts | 1 + 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/apps/web/src/app/settings/low-kdf.component.html b/apps/web/src/app/settings/low-kdf.component.html index 239c63bb9db..e140f345e9f 100644 --- a/apps/web/src/app/settings/low-kdf.component.html +++ b/apps/web/src/app/settings/low-kdf.component.html @@ -4,14 +4,14 @@ {{ "lowKdfIterations" | i18n }}
-

{{ "lowKdfIterationsDesc" | i18n }}

+

{{ "updateLowKdfIterationsDesc" | i18n }}

- {{ "changeKdfSettings" | i18n }} + {{ "updateKdfSettings" | i18n }}
diff --git a/apps/web/src/app/vault/individual-vault/vault.component.ts b/apps/web/src/app/vault/individual-vault/vault.component.ts index 7bd8cba33f9..2954e7e3b6a 100644 --- a/apps/web/src/app/vault/individual-vault/vault.component.ts +++ b/apps/web/src/app/vault/individual-vault/vault.component.ts @@ -32,6 +32,7 @@ import { SearchPipe } from "@bitwarden/angular/pipes/search.pipe"; import { DialogServiceAbstraction, SimpleDialogType } from "@bitwarden/angular/services/dialog"; import { ModalService } from "@bitwarden/angular/services/modal.service"; import { BroadcasterService } from "@bitwarden/common/abstractions/broadcaster.service"; +import { ConfigServiceAbstraction } from "@bitwarden/common/abstractions/config/config.service.abstraction"; import { CryptoService } from "@bitwarden/common/abstractions/crypto.service"; import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service"; import { I18nService } from "@bitwarden/common/abstractions/i18n.service"; @@ -47,6 +48,7 @@ import { Organization } from "@bitwarden/common/admin-console/models/domain/orga import { CollectionView } from "@bitwarden/common/admin-console/models/view/collection.view"; import { TokenService } from "@bitwarden/common/auth/abstractions/token.service"; import { DEFAULT_PBKDF2_ITERATIONS, EventType, KdfType } from "@bitwarden/common/enums"; +import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; import { ServiceUtils } from "@bitwarden/common/misc/serviceUtils"; import { Utils } from "@bitwarden/common/misc/utils"; import { TreeNode } from "@bitwarden/common/models/domain/tree-node"; @@ -171,7 +173,8 @@ export class VaultComponent implements OnInit, OnDestroy { private totpService: TotpService, private eventCollectionService: EventCollectionService, private searchService: SearchService, - private searchPipe: SearchPipe + private searchPipe: SearchPipe, + private configService: ConfigServiceAbstraction ) {} async ngOnInit() { @@ -186,8 +189,7 @@ export class VaultComponent implements OnInit, OnDestroy { first(), switchMap(async (params: Params) => { this.showVerifyEmail = !(await this.tokenService.getEmailVerified()); - // disable warning for March release -> add await this.isLowKdfIteration(); when ready - this.showLowKdf = false; + this.showLowKdf = await this.isLowKdfIteration(); await this.syncService.fullSync(false); const canAccessPremium = await this.stateService.getCanAccessPremium(); @@ -855,9 +857,17 @@ export class VaultComponent implements OnInit, OnDestroy { } async isLowKdfIteration() { - const kdfType = await this.stateService.getKdfType(); - const kdfOptions = await this.stateService.getKdfConfig(); - return kdfType === KdfType.PBKDF2_SHA256 && kdfOptions.iterations < DEFAULT_PBKDF2_ITERATIONS; + const showLowKdfEnabled = await this.configService.getFeatureFlagBool( + FeatureFlag.DisplayLowKdfIterationWarningFlag + ); + + if (showLowKdfEnabled) { + const kdfType = await this.stateService.getKdfType(); + const kdfOptions = await this.stateService.getKdfConfig(); + return kdfType === KdfType.PBKDF2_SHA256 && kdfOptions.iterations < DEFAULT_PBKDF2_ITERATIONS; + } + + return showLowKdfEnabled; } protected async repromptCipher(ciphers: CipherView[]) { diff --git a/apps/web/src/locales/en/messages.json b/apps/web/src/locales/en/messages.json index 69862d825b7..578caf9ad50 100644 --- a/apps/web/src/locales/en/messages.json +++ b/apps/web/src/locales/en/messages.json @@ -6564,11 +6564,8 @@ "lowKdfIterations": { "message": "Low KDF Iterations" }, - "lowKdfIterationsDesc": { - "message": "Increase your KDF encryption settings to improve the security of your account." - }, - "changeKdfSettings": { - "message": "Change KDF settings" + "updateLowKdfIterationsDesc": { + "message": "Update your encryption settings to meet new security recommendations and improve account protection." }, "changeKdfLoggedOutWarning": { "message": "Proceeding will log you out of all active sessions. You will need to log back in and complete two-step login setup. We recommend exporting your vault before changing your encryption settings to prevent data loss." @@ -6759,5 +6756,8 @@ "smProjectsDeleteBulkConfirmation": { "message": "The following projects can not be deleted. Would you like to continue?", "description": "The message shown to the user when bulk deleting projects and the user doesn't have access to some projects." + }, + "updateKdfSettings": { + "message": "Update KDF settings" } } diff --git a/libs/common/src/enums/feature-flag.enum.ts b/libs/common/src/enums/feature-flag.enum.ts index 8ba47bcd96d..47d7dfcd6a2 100644 --- a/libs/common/src/enums/feature-flag.enum.ts +++ b/libs/common/src/enums/feature-flag.enum.ts @@ -1,3 +1,4 @@ export enum FeatureFlag { DisplayEuEnvironmentFlag = "display-eu-environment", + DisplayLowKdfIterationWarningFlag = "display-kdf-iteration-warning", }