1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-08 11:33:31 +00:00

biometrics cleanup (#964)

This commit is contained in:
Matt Portune
2020-06-08 08:25:13 -04:00
committed by GitHub
parent ec7d87e757
commit 5da2f3279b
18 changed files with 117 additions and 257 deletions

View File

@@ -7,13 +7,13 @@ namespace Bit.Core.Abstractions
public interface IVaultTimeoutService
{
CipherString PinProtectedKey { get; set; }
bool FingerprintLocked { get; set; }
bool BiometricLocked { get; set; }
Task CheckVaultTimeoutAsync();
Task ClearAsync();
Task<bool> IsLockedAsync();
Task<Tuple<bool, bool>> IsPinLockSetAsync();
Task<bool> IsFingerprintLockSetAsync();
Task<bool> IsBiometricLockSetAsync();
Task LockAsync(bool allowSoftLock = false, bool userInitiated = false);
Task LogOutAsync();
Task SetVaultTimeoutOptionsAsync(int? timeout, string action);

View File

@@ -7,7 +7,7 @@
public static string VaultTimeoutKey = "lockOption";
public static string VaultTimeoutActionKey = "vaultTimeoutAction";
public static string LastActiveKey = "lastActive";
public static string FingerprintUnlockKey = "fingerprintUnlock";
public static string BiometricUnlockKey = "fingerprintUnlock";
public static string ProtectedPin = "protectedPin";
public static string PinProtectedKey = "pinProtectedKey";
public static string DefaultUriMatch = "defaultUriMatch";

View File

@@ -315,7 +315,7 @@ namespace Bit.Core.Services
await _cryptoService.SetEncPrivateKeyAsync(tokenResponse.PrivateKey);
}
_vaultTimeoutService.FingerprintLocked = false;
_vaultTimeoutService.BiometricLocked = false;
_messagingService.Send("loggedIn");
return result;
}

View File

@@ -48,8 +48,8 @@ namespace Bit.Core.Services
{
_key = key;
var option = await _storageService.GetAsync<int?>(Constants.VaultTimeoutKey);
var fingerprint = await _storageService.GetAsync<bool?>(Constants.FingerprintUnlockKey);
if (option.HasValue && !fingerprint.GetValueOrDefault())
var biometric = await _storageService.GetAsync<bool?>(Constants.BiometricUnlockKey);
if (option.HasValue && !biometric.GetValueOrDefault())
{
// If we have a lock option set, we do not store the key
return;
@@ -354,8 +354,8 @@ namespace Bit.Core.Services
{
var key = await GetKeyAsync();
var option = await _storageService.GetAsync<int?>(Constants.VaultTimeoutKey);
var fingerprint = await _storageService.GetAsync<bool?>(Constants.FingerprintUnlockKey);
if (!fingerprint.GetValueOrDefault() && (option != null || option == 0))
var biometric = await _storageService.GetAsync<bool?>(Constants.BiometricUnlockKey);
if (!biometric.GetValueOrDefault() && (option != null || option == 0))
{
await ClearKeyAsync();
_key = key;

View File

@@ -49,15 +49,15 @@ namespace Bit.Core.Services
}
public CipherString PinProtectedKey { get; set; } = null;
public bool FingerprintLocked { get; set; } = true;
public bool BiometricLocked { get; set; } = true;
public async Task<bool> IsLockedAsync()
{
var hasKey = await _cryptoService.HasKeyAsync();
if (hasKey)
{
var fingerprintSet = await IsFingerprintLockSetAsync();
if (fingerprintSet && FingerprintLocked)
var biometricSet = await IsBiometricLockSetAsync();
if (biometricSet && BiometricLocked)
{
return true;
}
@@ -120,8 +120,8 @@ namespace Bit.Core.Services
}
if (allowSoftLock)
{
FingerprintLocked = await IsFingerprintLockSetAsync();
if (FingerprintLocked)
BiometricLocked = await IsBiometricLockSetAsync();
if (BiometricLocked)
{
_messagingService.Send("locked", userInitiated);
_lockedCallback?.Invoke(userInitiated);
@@ -165,10 +165,10 @@ namespace Bit.Core.Services
return new Tuple<bool, bool>(protectedPin != null, pinProtectedKey != null);
}
public async Task<bool> IsFingerprintLockSetAsync()
public async Task<bool> IsBiometricLockSetAsync()
{
var fingerprintLock = await _storageService.GetAsync<bool?>(Constants.FingerprintUnlockKey);
return fingerprintLock.GetValueOrDefault();
var biometricLock = await _storageService.GetAsync<bool?>(Constants.BiometricUnlockKey);
return biometricLock.GetValueOrDefault();
}
public async Task ClearAsync()