Browse Source

add lastpass mfa dialog variant scaffolding; add yubikey variant (#6687)

pull/6693/head
Will Martin 2 years ago committed by GitHub
parent
commit
5b1c1d50eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      apps/browser/src/_locales/en/messages.json
  2. 3
      apps/desktop/src/locales/en/messages.json
  3. 2
      libs/importer/src/components/lastpass/dialog/lastpass-multifactor-prompt.component.html
  4. 20
      libs/importer/src/components/lastpass/dialog/lastpass-multifactor-prompt.component.ts
  5. 33
      libs/importer/src/components/lastpass/lastpass-direct-import-ui.service.ts

3
apps/browser/src/_locales/en/messages.json

@ -2674,5 +2674,8 @@ @@ -2674,5 +2674,8 @@
},
"collection": {
"message": "Collection"
},
"lastPassYubikeyDesc": {
"message": "Insert the YubiKey associated with your LastPass account into your computer's USB port, then touch its button."
}
}

3
apps/desktop/src/locales/en/messages.json

@ -2602,5 +2602,8 @@ @@ -2602,5 +2602,8 @@
},
"collection": {
"message": "Collection"
},
"lastPassYubikeyDesc": {
"message": "Insert the YubiKey associated with your LastPass account into your computer's USB port, then touch its button."
}
}

2
libs/importer/src/components/lastpass/dialog/lastpass-multifactor-prompt.component.html

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
</span>
<div bitDialogContent>
<p>{{ description | i18n }}</p>
<p>{{ descriptionI18nKey | i18n }}</p>
<bit-form-field class="!tw-mb-0">
<bit-label>{{ "passcode" | i18n }}</bit-label>
<input bitInput type="text" formControlName="passcode" appAutofocus appInputVerbatim />

20
libs/importer/src/components/lastpass/dialog/lastpass-multifactor-prompt.component.ts

@ -14,8 +14,10 @@ import { @@ -14,8 +14,10 @@ import {
TypographyModule,
} from "@bitwarden/components";
export type LastPassMultifactorPromptVariant = "otp" | "oob" | "yubikey";
type LastPassMultifactorPromptData = {
isOOB?: boolean;
variant: LastPassMultifactorPromptVariant;
};
@Component({
@ -34,7 +36,19 @@ type LastPassMultifactorPromptData = { @@ -34,7 +36,19 @@ type LastPassMultifactorPromptData = {
],
})
export class LastPassMultifactorPromptComponent {
protected description = this.data?.isOOB ? "lastPassOOBDesc" : "lastPassMFADesc";
private variant = this.data.variant;
protected get descriptionI18nKey(): string {
switch (this.variant) {
case "oob":
return "lastPassOOBDesc";
case "yubikey":
return "lastPassYubikeyDesc";
case "otp":
default:
return "lastPassMFADesc";
}
}
protected formGroup = new FormGroup({
passcode: new FormControl("", {
@ -56,7 +70,7 @@ export class LastPassMultifactorPromptComponent { @@ -56,7 +70,7 @@ export class LastPassMultifactorPromptComponent {
this.dialogRef.close(this.formGroup.value.passcode);
};
static open(dialogService: DialogService, data?: LastPassMultifactorPromptData) {
static open(dialogService: DialogService, data: LastPassMultifactorPromptData) {
return dialogService.open<string>(LastPassMultifactorPromptComponent, { data });
}
}

33
libs/importer/src/components/lastpass/lastpass-direct-import-ui.service.ts

@ -8,6 +8,10 @@ import { OtpResult, OobResult } from "../../importers/lastpass/access/models"; @@ -8,6 +8,10 @@ import { OtpResult, OobResult } from "../../importers/lastpass/access/models";
import { Ui } from "../../importers/lastpass/access/ui";
import { LastPassMultifactorPromptComponent } from "./dialog";
import { LastPassMultifactorPromptVariant } from "./dialog/lastpass-multifactor-prompt.component";
type OtpDialogVariant = Extract<LastPassMultifactorPromptVariant, "otp" | "yubikey">;
type OobDialogVariant = Extract<LastPassMultifactorPromptVariant, "oob">;
@Injectable({
providedIn: "root",
@ -17,18 +21,21 @@ export class LastPassDirectImportUIService implements Ui { @@ -17,18 +21,21 @@ export class LastPassDirectImportUIService implements Ui {
constructor(private dialogService: DialogService) {}
private async getOTPResult() {
this.mfaDialogRef = LastPassMultifactorPromptComponent.open(this.dialogService);
const passcode = await firstValueFrom(this.mfaDialogRef.closed);
private async getOTPResult(variant: OtpDialogVariant) {
const passcode = await this.openMFADialog(variant);
return new OtpResult(passcode, false);
}
private async getOOBResult() {
private async getOOBResult(variant: OobDialogVariant) {
const passcode = await this.openMFADialog(variant);
return new OobResult(false, passcode, false);
}
private openMFADialog(variant: LastPassMultifactorPromptVariant) {
this.mfaDialogRef = LastPassMultifactorPromptComponent.open(this.dialogService, {
isOOB: true,
variant,
});
const passcode = await firstValueFrom(this.mfaDialogRef.closed);
return new OobResult(false, passcode, false);
return firstValueFrom(this.mfaDialogRef.closed);
}
closeMFADialog() {
@ -36,24 +43,24 @@ export class LastPassDirectImportUIService implements Ui { @@ -36,24 +43,24 @@ export class LastPassDirectImportUIService implements Ui {
}
async provideGoogleAuthPasscode() {
return this.getOTPResult();
return this.getOTPResult("otp");
}
async provideMicrosoftAuthPasscode() {
return this.getOTPResult();
return this.getOTPResult("otp");
}
async provideYubikeyPasscode() {
return this.getOTPResult();
return this.getOTPResult("yubikey");
}
async approveLastPassAuth() {
return this.getOOBResult();
return this.getOOBResult("oob");
}
async approveDuo() {
return this.getOOBResult();
return this.getOOBResult("oob");
}
async approveSalesforceAuth() {
return this.getOOBResult();
return this.getOOBResult("oob");
}
}

Loading…
Cancel
Save