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
|
@Module
|
||||||
companion object {
|
companion object {
|
||||||
internal const val DB_ALIAS_PREFIX = "crypto_module_"
|
internal fun getKeyAlias(userMd5: String) = "crypto_module_$userMd5"
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
|
@ -59,7 +59,7 @@ internal abstract class CryptoModule {
|
||||||
return RealmConfiguration.Builder()
|
return RealmConfiguration.Builder()
|
||||||
.directory(directory)
|
.directory(directory)
|
||||||
.apply {
|
.apply {
|
||||||
realmKeysUtils.configureEncryption(this, "$DB_ALIAS_PREFIX$userMd5")
|
realmKeysUtils.configureEncryption(this, getKeyAlias(userMd5))
|
||||||
}
|
}
|
||||||
.name("crypto_store.realm")
|
.name("crypto_store.realm")
|
||||||
.modules(RealmCryptoStoreModule())
|
.modules(RealmCryptoStoreModule())
|
||||||
|
|
|
@ -62,7 +62,7 @@ internal class SessionRealmConfigurationFactory @Inject constructor(private val
|
||||||
.directory(directory)
|
.directory(directory)
|
||||||
.name(REALM_NAME)
|
.name(REALM_NAME)
|
||||||
.apply {
|
.apply {
|
||||||
realmKeysUtils.configureEncryption(this, "${SessionModule.DB_ALIAS_PREFIX}$userMd5")
|
realmKeysUtils.configureEncryption(this, SessionModule.getKeyAlias(userMd5))
|
||||||
}
|
}
|
||||||
.modules(SessionRealmModule())
|
.modules(SessionRealmModule())
|
||||||
.deleteRealmIfMigrationNeeded()
|
.deleteRealmIfMigrationNeeded()
|
||||||
|
|
|
@ -55,8 +55,7 @@ internal abstract class SessionModule {
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
companion object {
|
companion object {
|
||||||
|
internal fun getKeyAlias(userMd5: String) = "session_db_$userMd5"
|
||||||
internal const val DB_ALIAS_PREFIX = "session_db_"
|
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Provides
|
@Provides
|
||||||
|
|
|
@ -97,8 +97,8 @@ internal class DefaultSignOutTask @Inject constructor(private val context: Conte
|
||||||
userFile.deleteRecursively()
|
userFile.deleteRecursively()
|
||||||
|
|
||||||
Timber.d("SignOut: clear the database keys")
|
Timber.d("SignOut: clear the database keys")
|
||||||
realmKeysUtils.clear(SessionModule.DB_ALIAS_PREFIX + userMd5)
|
realmKeysUtils.clear(SessionModule.getKeyAlias(userMd5))
|
||||||
realmKeysUtils.clear(CryptoModule.DB_ALIAS_PREFIX + userMd5)
|
realmKeysUtils.clear(CryptoModule.getKeyAlias(userMd5))
|
||||||
|
|
||||||
// Sanity check
|
// Sanity check
|
||||||
if (BuildConfig.DEBUG) {
|
if (BuildConfig.DEBUG) {
|
||||||
|
|
Loading…
Reference in New Issue