Ensure key aliases are always computed the same way
This commit is contained in:
parent
215abea10a
commit
f432d15757
|
@ -47,7 +47,7 @@ internal abstract class CryptoModule {
|
|||
|
||||
@Module
|
||||
companion object {
|
||||
internal const val DB_ALIAS_PREFIX = "crypto_module_"
|
||||
internal fun getKeyAlias(userMd5: String) = "crypto_module_$userMd5"
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
|
@ -59,7 +59,7 @@ internal abstract class CryptoModule {
|
|||
return RealmConfiguration.Builder()
|
||||
.directory(directory)
|
||||
.apply {
|
||||
realmKeysUtils.configureEncryption(this, "$DB_ALIAS_PREFIX$userMd5")
|
||||
realmKeysUtils.configureEncryption(this, getKeyAlias(userMd5))
|
||||
}
|
||||
.name("crypto_store.realm")
|
||||
.modules(RealmCryptoStoreModule())
|
||||
|
|
|
@ -62,7 +62,7 @@ internal class SessionRealmConfigurationFactory @Inject constructor(private val
|
|||
.directory(directory)
|
||||
.name(REALM_NAME)
|
||||
.apply {
|
||||
realmKeysUtils.configureEncryption(this, "${SessionModule.DB_ALIAS_PREFIX}$userMd5")
|
||||
realmKeysUtils.configureEncryption(this, SessionModule.getKeyAlias(userMd5))
|
||||
}
|
||||
.modules(SessionRealmModule())
|
||||
.deleteRealmIfMigrationNeeded()
|
||||
|
|
|
@ -55,8 +55,7 @@ internal abstract class SessionModule {
|
|||
|
||||
@Module
|
||||
companion object {
|
||||
|
||||
internal const val DB_ALIAS_PREFIX = "session_db_"
|
||||
internal fun getKeyAlias(userMd5: String) = "session_db_$userMd5"
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
|
|
|
@ -97,8 +97,8 @@ internal class DefaultSignOutTask @Inject constructor(private val context: Conte
|
|||
userFile.deleteRecursively()
|
||||
|
||||
Timber.d("SignOut: clear the database keys")
|
||||
realmKeysUtils.clear(SessionModule.DB_ALIAS_PREFIX + userMd5)
|
||||
realmKeysUtils.clear(CryptoModule.DB_ALIAS_PREFIX + userMd5)
|
||||
realmKeysUtils.clear(SessionModule.getKeyAlias(userMd5))
|
||||
realmKeysUtils.clear(CryptoModule.getKeyAlias(userMd5))
|
||||
|
||||
// Sanity check
|
||||
if (BuildConfig.DEBUG) {
|
||||
|
|
Loading…
Reference in New Issue