BIT-2259: Check device trust after each vault unlock (#1286)

This commit is contained in:
David Perez
2024-04-18 14:52:23 -05:00
committed by Álison Fernandes
parent dae98111e6
commit 1365a2a4fe
5 changed files with 27 additions and 17 deletions

View File

@@ -439,7 +439,6 @@ class AuthRepositoryImpl(
)
authDiskSource.storeUserKey(userId = userId, userKey = asymmetricalKey)
trustedDeviceManager.trustThisDeviceIfNecessary(userId = userId)
vaultRepository.syncIfNecessary()
return LoginResult.Success
}
@@ -1385,7 +1384,6 @@ class AuthRepositoryImpl(
organizationKeys = null,
)
authDiskSource.storeUserKey(userId = userId, userKey = userKey)
trustedDeviceManager.trustThisDeviceIfNecessary(userId = userId)
}
authDiskSource.storePendingAuthRequest(
userId = userId,

View File

@@ -8,6 +8,7 @@ import com.bitwarden.crypto.HashPurpose
import com.bitwarden.crypto.Kdf
import com.x8bit.bitwarden.data.auth.datasource.disk.AuthDiskSource
import com.x8bit.bitwarden.data.auth.datasource.sdk.AuthSdkSource
import com.x8bit.bitwarden.data.auth.manager.TrustedDeviceManager
import com.x8bit.bitwarden.data.auth.manager.UserLogoutManager
import com.x8bit.bitwarden.data.auth.repository.util.toSdkParams
import com.x8bit.bitwarden.data.auth.repository.util.userSwitchingChangesFlow
@@ -62,7 +63,8 @@ class VaultLockManagerImpl(
private val settingsRepository: SettingsRepository,
private val appForegroundManager: AppForegroundManager,
private val userLogoutManager: UserLogoutManager,
private val dispatcherManager: DispatcherManager,
private val trustedDeviceManager: TrustedDeviceManager,
dispatcherManager: DispatcherManager,
private val elapsedRealtimeMillisProvider: () -> Long = { SystemClock.elapsedRealtime() },
) : VaultLockManager {
private val unconfinedScope = CoroutineScope(dispatcherManager.unconfined)
@@ -165,6 +167,9 @@ class VaultLockManagerImpl(
if (it is VaultUnlockResult.Success) {
clearInvalidUnlockCount(userId = userId)
setVaultToUnlocked(userId = userId)
trustedDeviceManager.trustThisDeviceIfNecessary(
userId = userId,
)
} else {
incrementInvalidUnlockCount(userId = userId)
}

View File

@@ -3,6 +3,7 @@ package com.x8bit.bitwarden.data.vault.manager.di
import android.content.Context
import com.x8bit.bitwarden.data.auth.datasource.disk.AuthDiskSource
import com.x8bit.bitwarden.data.auth.datasource.sdk.AuthSdkSource
import com.x8bit.bitwarden.data.auth.manager.TrustedDeviceManager
import com.x8bit.bitwarden.data.auth.manager.UserLogoutManager
import com.x8bit.bitwarden.data.platform.manager.AppForegroundManager
import com.x8bit.bitwarden.data.platform.manager.dispatcher.DispatcherManager
@@ -52,6 +53,7 @@ object VaultManagerModule {
appForegroundManager: AppForegroundManager,
userLogoutManager: UserLogoutManager,
dispatcherManager: DispatcherManager,
trustedDeviceManager: TrustedDeviceManager,
): VaultLockManager =
VaultLockManagerImpl(
authDiskSource = authDiskSource,
@@ -61,6 +63,7 @@ object VaultManagerModule {
appForegroundManager = appForegroundManager,
userLogoutManager = userLogoutManager,
dispatcherManager = dispatcherManager,
trustedDeviceManager = trustedDeviceManager,
)
@Provides