1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-31 08:43:54 +00:00
This commit is contained in:
Bernd Schoolmann
2025-11-25 19:09:48 +01:00
parent 7e14c814dc
commit 9bc684809c

View File

@@ -23,7 +23,7 @@ export class MinimumKdfMigration implements EncryptedMigration {
private readonly logService: LogService,
private readonly configService: ConfigService,
private readonly masterPasswordService: MasterPasswordServiceAbstraction,
) {}
) { }
async runMigrations(userId: UserId, masterPassword: string | null): Promise<void> {
assertNonNullish(userId, "userId");
@@ -42,24 +42,36 @@ export class MinimumKdfMigration implements EncryptedMigration {
async needsMigration(userId: UserId): Promise<MigrationRequirement> {
assertNonNullish(userId, "userId");
this.logService.info(`[MinimumKdfMigration] Checking if user ${userId} needs KDF migration.`);
if (!(await this.masterPasswordService.userHasMasterPassword(userId))) {
this.logService.info("[MinimumKdfMigration] User has no master password, skipping migration.");
return "noMigrationNeeded";
}
// Only PBKDF2 users below the minimum iteration count need migration
const kdfConfig = await this.kdfConfigService.getKdfConfig(userId);
this.logService.info("[MinimumKdfMigration] Current KDF config: " + JSON.stringify(kdfConfig));
if (
kdfConfig.kdfType !== KdfType.PBKDF2_SHA256 ||
kdfConfig.iterations >= 600000 // QA override
) {
this.logService.info(
"[MinimumKdfMigration] User KDF config meets or exceeds minimum requirements, no migration needed.",
);
return "noMigrationNeeded";
}
if (!(await this.configService.getFeatureFlag(FeatureFlag.ForceUpdateKDFSettings))) {
this.logService.info(
"[MinimumKdfMigration] ForceUpdateKDFSettings feature flag is not enabled, skipping migration.",
);
return "noMigrationNeeded";
}
this.logService.info(
"[MinimumKdfMigration] User KDF config below minimum requirements, migration needed.",
);
return "needsMigrationWithMasterPassword";
}
}