1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-10 21:33:27 +00:00

[PM-17035] Fix biometric unlock badge in mv2 (#12854)

* Fix biometrics not working in firefox or windows

* Remove logs

* Update badge after biometric unlock

* Add removal todo note

* Remove debug logging

* Fix type warnings

* Fix userkey typing in background biometrics service

* Simplify types for userkey in foreground-browser-biometrics and runtime.background.ts

* Add process reload logging

* Fix autoprompt not working when no process reload happened

* Fix biometric unlock badge in mv2

* Fix instant reprompt on firefox lock

* Remove biometrics autoprompt on firefox (#12856)
This commit is contained in:
Bernd Schoolmann
2025-01-15 17:59:39 +01:00
committed by GitHub
parent 58bd44fa2f
commit a5dce05354
5 changed files with 21 additions and 2 deletions

View File

@@ -20,7 +20,7 @@
{{ biometricUnavailabilityReason }} {{ biometricUnavailabilityReason }}
</bit-hint> </bit-hint>
</bit-form-control> </bit-form-control>
<bit-form-control class="tw-pl-5" *ngIf="this.form.value.biometric"> <bit-form-control class="tw-pl-5" *ngIf="this.form.value.biometric && showAutoPrompt">
<input <input
bitCheckbox bitCheckbox
id="autoBiometricsPrompt" id="autoBiometricsPrompt"

View File

@@ -29,6 +29,7 @@ import { PolicyService } from "@bitwarden/common/admin-console/abstractions/poli
import { PolicyType } from "@bitwarden/common/admin-console/enums"; import { PolicyType } from "@bitwarden/common/admin-console/enums";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction"; import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
import { DeviceType } from "@bitwarden/common/enums";
import { VaultTimeoutAction } from "@bitwarden/common/enums/vault-timeout-action.enum"; import { VaultTimeoutAction } from "@bitwarden/common/enums/vault-timeout-action.enum";
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service"; import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
@@ -106,6 +107,7 @@ export class AccountSecurityComponent implements OnInit, OnDestroy {
hasVaultTimeoutPolicy = false; hasVaultTimeoutPolicy = false;
biometricUnavailabilityReason: string; biometricUnavailabilityReason: string;
showChangeMasterPass = true; showChangeMasterPass = true;
showAutoPrompt = true;
form = this.formBuilder.group({ form = this.formBuilder.group({
vaultTimeout: [null as VaultTimeout | null], vaultTimeout: [null as VaultTimeout | null],
@@ -141,6 +143,11 @@ export class AccountSecurityComponent implements OnInit, OnDestroy {
) {} ) {}
async ngOnInit() { async ngOnInit() {
// Firefox popup closes when unfocused by biometrics, blocking all unlock methods
if (this.platformUtilsService.getDevice() === DeviceType.FirefoxExtension) {
this.showAutoPrompt = false;
}
const hasMasterPassword = await this.userVerificationService.hasMasterPassword(); const hasMasterPassword = await this.userVerificationService.hasMasterPassword();
this.showMasterPasswordOnClientRestartOption = hasMasterPassword; this.showMasterPasswordOnClientRestartOption = hasMasterPassword;
const maximumVaultTimeoutPolicy = this.policyService.get$(PolicyType.MaximumVaultTimeout); const maximumVaultTimeoutPolicy = this.policyService.get$(PolicyType.MaximumVaultTimeout);

View File

@@ -665,6 +665,7 @@ export default class MainBackground {
this.logService, this.logService,
this.keyService, this.keyService,
this.biometricStateService, this.biometricStateService,
this.messagingService,
); );
this.appIdService = new AppIdService(this.storageService, this.logService); this.appIdService = new AppIdService(this.storageService, this.logService);

View File

@@ -1,6 +1,7 @@
import { Injectable } from "@angular/core"; import { Injectable } from "@angular/core";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
import { Utils } from "@bitwarden/common/platform/misc/utils"; import { Utils } from "@bitwarden/common/platform/misc/utils";
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key"; import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
import { UserId } from "@bitwarden/common/types/guid"; import { UserId } from "@bitwarden/common/types/guid";
@@ -23,6 +24,7 @@ export class BackgroundBrowserBiometricsService extends BiometricsService {
private logService: LogService, private logService: LogService,
private keyService: KeyService, private keyService: KeyService,
private biometricStateService: BiometricStateService, private biometricStateService: BiometricStateService,
private messagingService: MessagingService,
) { ) {
super(); super();
} }
@@ -98,6 +100,8 @@ export class BackgroundBrowserBiometricsService extends BiometricsService {
await this.biometricStateService.setBiometricUnlockEnabled(true); await this.biometricStateService.setBiometricUnlockEnabled(true);
await this.biometricStateService.setFingerprintValidated(true); await this.biometricStateService.setFingerprintValidated(true);
await this.keyService.setUserKey(userKey, userId); await this.keyService.setUserKey(userKey, userId);
// to update badge and other things
this.messagingService.send("switchAccount", { userId });
return userKey; return userKey;
} }
} else { } else {
@@ -116,6 +120,8 @@ export class BackgroundBrowserBiometricsService extends BiometricsService {
await this.biometricStateService.setBiometricUnlockEnabled(true); await this.biometricStateService.setBiometricUnlockEnabled(true);
await this.biometricStateService.setFingerprintValidated(true); await this.biometricStateService.setFingerprintValidated(true);
await this.keyService.setUserKey(userKey, userId); await this.keyService.setUserKey(userKey, userId);
// to update badge and other things
this.messagingService.send("switchAccount", { userId });
return userKey; return userKey;
} }
} else { } else {

View File

@@ -30,7 +30,7 @@ import {
MasterPasswordVerification, MasterPasswordVerification,
MasterPasswordVerificationResponse, MasterPasswordVerificationResponse,
} from "@bitwarden/common/auth/types/verification"; } from "@bitwarden/common/auth/types/verification";
import { ClientType } from "@bitwarden/common/enums"; import { ClientType, DeviceType } from "@bitwarden/common/enums";
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service"; import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
@@ -301,6 +301,11 @@ export class LockComponent implements OnInit, OnDestroy {
} }
if (this.clientType === "browser") { if (this.clientType === "browser") {
// Firefox closes the popup when unfocused, so this would block all unlock methods
if (this.platformUtilsService.getDevice() === DeviceType.FirefoxExtension) {
return;
}
if ( if (
this.unlockOptions.biometrics.enabled && this.unlockOptions.biometrics.enabled &&
autoPromptBiometrics && autoPromptBiometrics &&