Browse Source

[PM-27086] add flagged logic to InputPasswordComponent.submit()

auth/pm-27086/input-password-use-new-km-data-types
rr-bw 5 days ago
parent
commit
b1660e33a9
No known key found for this signature in database
GPG Key ID: 3FA13C3ADEE51D5D
  1. 31
      libs/auth/src/angular/input-password/input-password.component.ts
  2. 2
      libs/auth/src/angular/input-password/password-input-result.ts
  3. 1
      libs/common/src/enums/feature-flag.enum.ts

31
libs/auth/src/angular/input-password/input-password.component.ts

@ -10,7 +10,9 @@ import { @@ -10,7 +10,9 @@ import {
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
import { MasterPasswordPolicyOptions } from "@bitwarden/common/admin-console/models/domain/master-password-policy-options";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { MasterPasswordServiceAbstraction } from "@bitwarden/common/key-management/master-password/abstractions/master-password.service.abstraction";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
@ -209,6 +211,7 @@ export class InputPasswordComponent implements OnInit { @@ -209,6 +211,7 @@ export class InputPasswordComponent implements OnInit {
constructor(
private auditService: AuditService,
private cipherService: CipherService,
private configService: ConfigService,
private dialogService: DialogService,
private formBuilder: FormBuilder,
private i18nService: I18nService,
@ -312,7 +315,7 @@ export class InputPasswordComponent implements OnInit { @@ -312,7 +315,7 @@ export class InputPasswordComponent implements OnInit {
}
if (!this.email) {
throw new Error("Email is required to create master key.");
throw new Error("Email not found.");
}
// 1. Determine kdfConfig
@ -320,13 +323,13 @@ export class InputPasswordComponent implements OnInit { @@ -320,13 +323,13 @@ export class InputPasswordComponent implements OnInit {
this.kdfConfig = DEFAULT_KDF_CONFIG;
} else {
if (!this.userId) {
throw new Error("userId not passed down");
throw new Error("userId not found.");
}
this.kdfConfig = await firstValueFrom(this.kdfConfigService.getKdfConfig$(this.userId));
}
if (this.kdfConfig == null) {
throw new Error("KdfConfig is required to create master key.");
throw new Error("KdfConfig not found.");
}
const salt =
@ -334,7 +337,7 @@ export class InputPasswordComponent implements OnInit { @@ -334,7 +337,7 @@ export class InputPasswordComponent implements OnInit {
? await firstValueFrom(this.masterPasswordService.saltForUser$(this.userId))
: this.masterPasswordService.emailToSalt(this.email);
if (salt == null) {
throw new Error("Salt is required to create master key.");
throw new Error("Salt not found.");
}
// 2. Verify current password is correct (if necessary)
@ -361,6 +364,26 @@ export class InputPasswordComponent implements OnInit { @@ -361,6 +364,26 @@ export class InputPasswordComponent implements OnInit {
return;
}
const newApisFlagEnabled = await this.configService.getFeatureFlag(
FeatureFlag.PM27086_UpdateAuthenticationApisForInputPassword,
);
if (newApisFlagEnabled) {
// 4. Build a PasswordInputResult object
const passwordInputResult: PasswordInputResult = {
currentPassword,
newPassword,
kdfConfig: this.kdfConfig,
salt,
newPasswordHint,
rotateUserKey: this.formGroup.controls.rotateUserKey?.value ?? false,
};
// 5. Emit and return PasswordInputResult object
this.onPasswordFormSubmit.emit(passwordInputResult);
return passwordInputResult;
}
// 4. Create cryptographic keys and build a PasswordInputResult object
const newMasterKey = await this.keyService.makeMasterKey(
newPassword,

2
libs/auth/src/angular/input-password/password-input-result.ts

@ -10,6 +10,8 @@ export interface PasswordInputResult { @@ -10,6 +10,8 @@ export interface PasswordInputResult {
newPasswordHint?: string;
rotateUserKey?: boolean;
// The deprecated properties below will be removed in PM-28143: https://bitwarden.atlassian.net/browse/PM-28143
/** @deprecated This low-level cryptographic state will be removed. It will be replaced by high level calls to masterpassword service, in the consumers of this interface. */
currentMasterKey?: MasterKey;
/** @deprecated */

1
libs/common/src/enums/feature-flag.enum.ts

@ -132,6 +132,7 @@ export const DefaultFeatureFlagValue = { @@ -132,6 +132,7 @@ export const DefaultFeatureFlagValue = {
/* Auth */
[FeatureFlag.PM23801_PrefetchPasswordPrelogin]: FALSE,
[FeatureFlag.PM27086_UpdateAuthenticationApisForInputPassword]: FALSE,
/* Billing */
[FeatureFlag.TrialPaymentOptional]: FALSE,

Loading…
Cancel
Save