π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Enhance secure storage management by revoking auth secret key on logout and updating secureStorageKeys in Configuration class.
AmanRajSinghMouryaa64f0a5592b6
diff --git a/mobile/apps/auth/lib/core/configuration.dart b/mobile/apps/auth/lib/core/configuration.dartindex 79299ed3c6..026fbf6578 100644--- a/mobile/apps/auth/lib/core/configuration.dart+++ b/mobile/apps/auth/lib/core/configuration.dart@@ -40,6 +40,13 @@ class Configuration extends BaseConfiguration {);}+ @override+ // Also remove the auth secret key so cached sessions are fully revoked.+ List<String> get secureStorageKeys => [+ ...super.secureStorageKeys,+ authSecretKeyKey,+ ];+@overrideFuture<void> logout({bool autoLogout = false}) async {_authSecretKey = null;diff --git a/mobile/packages/configuration/lib/base_configuration.dart b/mobile/packages/configuration/lib/base_configuration.dartindex 00f9c3fa72..6d4bfb6bb0 100644--- a/mobile/packages/configuration/lib/base_configuration.dart+++ b/mobile/packages/configuration/lib/base_configuration.dart@@ -35,7 +35,6 @@ class BaseConfiguration {static const userIDKey = "user_id";static const endPointKey = "endpoint";static const lastTempFolderClearTimeKey = "last_temp_folder_clear_time";- static const offlineAuthSecretKey = "offline_auth_secret_key";final kTempFolderDeletionTimeBuffer = const Duration(days: 1).inMicroseconds;@@ -53,10 +52,14 @@ class BaseConfiguration {String? _volatilePassword;- // Keys that should not be deleted during logout- // These keys are necessary for functionality that needs to work even when users- // aren't signed in, such as using Auth without backup- List<String> preservedKeys = [offlineAuthSecretKey];+ // Default secure storage keys that should be wiped when the user logs out.+ static const List<String> _defaultSecureStorageKeysToDelete = [+ keyKey,+ secretKeyKey,+ ];++ // Descendants can override to append additional keys that must be cleared.+ List<String> get secureStorageKeys => _defaultSecureStorageKeysToDelete;Future<void> init(List<EnteBaseDatabase> dbs) async {_databases = dbs;@@ -85,12 +88,8 @@ class BaseConfiguration {}Future<void> resetSecureStorage() async {- // Delete all keys except preserved ones- final allKeys = await _secureStorage.readAll();- for (final key in allKeys.keys) {- if (!preservedKeys.contains(key)) {- await _secureStorage.delete(key: key);- }+ for (final key in secureStorageKeys.toSet()) {+ await _secureStorage.delete(key: key);}}