From 905cc3807d728dfd00ff3b47c5a22b7058976baa Mon Sep 17 00:00:00 2001 From: David Perez Date: Tue, 2 Apr 2024 09:36:32 -0500 Subject: [PATCH] Persist device key past a logout (#1207) --- .../data/auth/datasource/disk/AuthDiskSourceImpl.kt | 4 +++- .../data/auth/datasource/disk/AuthDiskSourceTest.kt | 5 ----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/x8bit/bitwarden/data/auth/datasource/disk/AuthDiskSourceImpl.kt b/app/src/main/java/com/x8bit/bitwarden/data/auth/datasource/disk/AuthDiskSourceImpl.kt index ecdc8859d9..31b483f057 100644 --- a/app/src/main/java/com/x8bit/bitwarden/data/auth/datasource/disk/AuthDiskSourceImpl.kt +++ b/app/src/main/java/com/x8bit/bitwarden/data/auth/datasource/disk/AuthDiskSourceImpl.kt @@ -126,12 +126,14 @@ class AuthDiskSourceImpl( storePrivateKey(userId = userId, privateKey = null) storeOrganizationKeys(userId = userId, organizationKeys = null) storeOrganizations(userId = userId, organizations = null) - storeDeviceKey(userId = userId, deviceKey = null) storePendingAuthRequest(userId = userId, pendingAuthRequest = null) storeUserBiometricUnlockKey(userId = userId, biometricsKey = null) storeMasterPasswordHash(userId = userId, passwordHash = null) storePolicies(userId = userId, policies = null) storeAccountTokens(userId = userId, accountTokens = null) + + // Do not remove the DeviceKey on logout, that is persisted indefinitely unless + // the server no longer trusts the device. } override fun getLastActiveTimeMillis(userId: String): Long? = diff --git a/app/src/test/java/com/x8bit/bitwarden/data/auth/datasource/disk/AuthDiskSourceTest.kt b/app/src/test/java/com/x8bit/bitwarden/data/auth/datasource/disk/AuthDiskSourceTest.kt index ccddc5d4a5..1ffcf35839 100644 --- a/app/src/test/java/com/x8bit/bitwarden/data/auth/datasource/disk/AuthDiskSourceTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/data/auth/datasource/disk/AuthDiskSourceTest.kt @@ -182,10 +182,6 @@ class AuthDiskSourceTest { fun `clearData should clear all necessary data for the given user`() { val userId = "userId" - authDiskSource.storeDeviceKey( - userId = userId, - deviceKey = "9876-5432-1234", - ) authDiskSource.storePendingAuthRequest( userId = userId, pendingAuthRequest = PendingAuthRequestJson( @@ -233,7 +229,6 @@ class AuthDiskSourceTest { authDiskSource.clearData(userId = userId) - assertNull(authDiskSource.getDeviceKey(userId = userId)) assertNull(authDiskSource.getPendingAuthRequest(userId = userId)) assertNull(authDiskSource.getUserBiometricUnlockKey(userId = userId)) assertNull(authDiskSource.getLastActiveTimeMillis(userId = userId))