add lastpass mfa dialog variant scaffolding; add yubikey variant (#6687)
This commit is contained in:
parent
67bc8d591f
commit
5b1c1d50eb
|
@ -2674,5 +2674,8 @@
|
||||||
},
|
},
|
||||||
"collection": {
|
"collection": {
|
||||||
"message": "Collection"
|
"message": "Collection"
|
||||||
|
},
|
||||||
|
"lastPassYubikeyDesc": {
|
||||||
|
"message": "Insert the YubiKey associated with your LastPass account into your computer's USB port, then touch its button."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2602,5 +2602,8 @@
|
||||||
},
|
},
|
||||||
"collection": {
|
"collection": {
|
||||||
"message": "Collection"
|
"message": "Collection"
|
||||||
|
},
|
||||||
|
"lastPassYubikeyDesc": {
|
||||||
|
"message": "Insert the YubiKey associated with your LastPass account into your computer's USB port, then touch its button."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<div bitDialogContent>
|
<div bitDialogContent>
|
||||||
<p>{{ description | i18n }}</p>
|
<p>{{ descriptionI18nKey | i18n }}</p>
|
||||||
<bit-form-field class="!tw-mb-0">
|
<bit-form-field class="!tw-mb-0">
|
||||||
<bit-label>{{ "passcode" | i18n }}</bit-label>
|
<bit-label>{{ "passcode" | i18n }}</bit-label>
|
||||||
<input bitInput type="text" formControlName="passcode" appAutofocus appInputVerbatim />
|
<input bitInput type="text" formControlName="passcode" appAutofocus appInputVerbatim />
|
||||||
|
|
|
@ -14,8 +14,10 @@ import {
|
||||||
TypographyModule,
|
TypographyModule,
|
||||||
} from "@bitwarden/components";
|
} from "@bitwarden/components";
|
||||||
|
|
||||||
|
export type LastPassMultifactorPromptVariant = "otp" | "oob" | "yubikey";
|
||||||
|
|
||||||
type LastPassMultifactorPromptData = {
|
type LastPassMultifactorPromptData = {
|
||||||
isOOB?: boolean;
|
variant: LastPassMultifactorPromptVariant;
|
||||||
};
|
};
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -34,7 +36,19 @@ type LastPassMultifactorPromptData = {
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class LastPassMultifactorPromptComponent {
|
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({
|
protected formGroup = new FormGroup({
|
||||||
passcode: new FormControl("", {
|
passcode: new FormControl("", {
|
||||||
|
@ -56,7 +70,7 @@ export class LastPassMultifactorPromptComponent {
|
||||||
this.dialogRef.close(this.formGroup.value.passcode);
|
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 });
|
return dialogService.open<string>(LastPassMultifactorPromptComponent, { data });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,10 @@ import { OtpResult, OobResult } from "../../importers/lastpass/access/models";
|
||||||
import { Ui } from "../../importers/lastpass/access/ui";
|
import { Ui } from "../../importers/lastpass/access/ui";
|
||||||
|
|
||||||
import { LastPassMultifactorPromptComponent } from "./dialog";
|
import { LastPassMultifactorPromptComponent } from "./dialog";
|
||||||
|
import { LastPassMultifactorPromptVariant } from "./dialog/lastpass-multifactor-prompt.component";
|
||||||
|
|
||||||
|
type OtpDialogVariant = Extract<LastPassMultifactorPromptVariant, "otp" | "yubikey">;
|
||||||
|
type OobDialogVariant = Extract<LastPassMultifactorPromptVariant, "oob">;
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: "root",
|
providedIn: "root",
|
||||||
|
@ -17,43 +21,46 @@ export class LastPassDirectImportUIService implements Ui {
|
||||||
|
|
||||||
constructor(private dialogService: DialogService) {}
|
constructor(private dialogService: DialogService) {}
|
||||||
|
|
||||||
private async getOTPResult() {
|
private async getOTPResult(variant: OtpDialogVariant) {
|
||||||
this.mfaDialogRef = LastPassMultifactorPromptComponent.open(this.dialogService);
|
const passcode = await this.openMFADialog(variant);
|
||||||
const passcode = await firstValueFrom(this.mfaDialogRef.closed);
|
|
||||||
return new OtpResult(passcode, false);
|
return new OtpResult(passcode, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getOOBResult() {
|
private async getOOBResult(variant: OobDialogVariant) {
|
||||||
this.mfaDialogRef = LastPassMultifactorPromptComponent.open(this.dialogService, {
|
const passcode = await this.openMFADialog(variant);
|
||||||
isOOB: true,
|
|
||||||
});
|
|
||||||
const passcode = await firstValueFrom(this.mfaDialogRef.closed);
|
|
||||||
return new OobResult(false, passcode, false);
|
return new OobResult(false, passcode, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private openMFADialog(variant: LastPassMultifactorPromptVariant) {
|
||||||
|
this.mfaDialogRef = LastPassMultifactorPromptComponent.open(this.dialogService, {
|
||||||
|
variant,
|
||||||
|
});
|
||||||
|
return firstValueFrom(this.mfaDialogRef.closed);
|
||||||
|
}
|
||||||
|
|
||||||
closeMFADialog() {
|
closeMFADialog() {
|
||||||
this.mfaDialogRef?.close();
|
this.mfaDialogRef?.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
async provideGoogleAuthPasscode() {
|
async provideGoogleAuthPasscode() {
|
||||||
return this.getOTPResult();
|
return this.getOTPResult("otp");
|
||||||
}
|
}
|
||||||
|
|
||||||
async provideMicrosoftAuthPasscode() {
|
async provideMicrosoftAuthPasscode() {
|
||||||
return this.getOTPResult();
|
return this.getOTPResult("otp");
|
||||||
}
|
}
|
||||||
|
|
||||||
async provideYubikeyPasscode() {
|
async provideYubikeyPasscode() {
|
||||||
return this.getOTPResult();
|
return this.getOTPResult("yubikey");
|
||||||
}
|
}
|
||||||
|
|
||||||
async approveLastPassAuth() {
|
async approveLastPassAuth() {
|
||||||
return this.getOOBResult();
|
return this.getOOBResult("oob");
|
||||||
}
|
}
|
||||||
async approveDuo() {
|
async approveDuo() {
|
||||||
return this.getOOBResult();
|
return this.getOOBResult("oob");
|
||||||
}
|
}
|
||||||
async approveSalesforceAuth() {
|
async approveSalesforceAuth() {
|
||||||
return this.getOOBResult();
|
return this.getOOBResult("oob");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue