Browse Source

Vault should be locked if key is not in memory

Key is loaded on startup if auto key exists.
fix-never-lock-with-biometric-no-prompt
Matt Gibson 5 years ago
parent
commit
b0c09cf751
  1. 1
      angular/src/components/lock.component.ts
  2. 1
      common/src/abstractions/vaultTimeout.service.ts
  3. 13
      common/src/services/vaultTimeout.service.ts

1
angular/src/components/lock.component.ts

@ -182,7 +182,6 @@ export class LockComponent implements OnInit { @@ -182,7 +182,6 @@ export class LockComponent implements OnInit {
private async doContinue() {
this.vaultTimeoutService.biometricLocked = false;
this.vaultTimeoutService.everBeenUnlocked = true;
this.vaultTimeoutService.manuallyOrTimerLocked = false;
const disableFavicon = await this.storageService.get<boolean>(ConstantsService.disableFaviconKey);
await this.stateService.save(ConstantsService.disableFaviconKey, !!disableFavicon);
this.messagingService.send('unlocked');

1
common/src/abstractions/vaultTimeout.service.ts

@ -2,7 +2,6 @@ import { EncString } from '../models/domain/encString'; @@ -2,7 +2,6 @@ import { EncString } from '../models/domain/encString';
export abstract class VaultTimeoutService {
biometricLocked: boolean;
manuallyOrTimerLocked: boolean;
everBeenUnlocked: boolean;
pinProtectedKey: EncString;
isLocked: () => Promise<boolean>;

13
common/src/services/vaultTimeout.service.ts

@ -18,7 +18,6 @@ export class VaultTimeoutService implements VaultTimeoutServiceAbstraction { @@ -18,7 +18,6 @@ export class VaultTimeoutService implements VaultTimeoutServiceAbstraction {
pinProtectedKey: EncString = null;
biometricLocked: boolean = true;
everBeenUnlocked: boolean = false;
manuallyOrTimerLocked: boolean = false;
private inited = false;
@ -48,17 +47,12 @@ export class VaultTimeoutService implements VaultTimeoutServiceAbstraction { @@ -48,17 +47,12 @@ export class VaultTimeoutService implements VaultTimeoutServiceAbstraction {
// Keys aren't stored for a device that is locked or logged out.
async isLocked(): Promise<boolean> {
// Handle never lock startup situation
if (await this.cryptoService.hasKeyStored('auto') && !this.everBeenUnlocked) {
await this.cryptoService.getKey('auto');
}
const hasKey = await this.cryptoService.hasKey();
if (hasKey) {
if ((await this.isBiometricLockSet() && this.biometricLocked) || this.manuallyOrTimerLocked) {
return true;
}
}
return !hasKey;
return !this.cryptoService.hasKeyInMemory();
}
async checkVaultTimeout(): Promise<void> {
@ -108,7 +102,7 @@ export class VaultTimeoutService implements VaultTimeoutServiceAbstraction { @@ -108,7 +102,7 @@ export class VaultTimeoutService implements VaultTimeoutServiceAbstraction {
}
this.biometricLocked = true;
this.manuallyOrTimerLocked = true;
this.everBeenUnlocked = true;
await this.cryptoService.clearKey(false);
await this.cryptoService.clearOrgKeys(true);
await this.cryptoService.clearKeyPair(true);
@ -149,7 +143,6 @@ export class VaultTimeoutService implements VaultTimeoutServiceAbstraction { @@ -149,7 +143,6 @@ export class VaultTimeoutService implements VaultTimeoutServiceAbstraction {
clear(): Promise<any> {
this.everBeenUnlocked = false;
this.manuallyOrTimerLocked = false;
this.pinProtectedKey = null;
return this.storageService.remove(ConstantsService.protectedPin);
}

Loading…
Cancel
Save