Skip to content

Commit

Permalink
Force to configure secure backup
Browse files Browse the repository at this point in the history
  • Loading branch information
yostyle committed Nov 24, 2023
1 parent 781ef3e commit 84cfc4c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ class BootstrapSetupRecoveryKeyFragment :

private fun renderBackupMethodActions(method: SecureBackupMethod) = with(views) {
bootstrapSetupSecureUseSecurityKey.isVisible = method.isKeyAvailable
// Tchap: Hide Security Passphrase
// views.bootstrapSetupSecureUseSecurityPassphrase.isVisible = method.isPassphraseAvailable
// views.bootstrapSetupSecureUseSecurityPassphraseSeparator.isVisible = method.isPassphraseAvailable
bootstrapSetupSecureUseSecurityPassphrase.isVisible = method.isPassphraseAvailable
bootstrapSetupSecureUseSecurityPassphraseSeparator.isVisible = method.isPassphraseAvailable
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import org.matrix.android.sdk.api.auth.UserPasswordAuth
import org.matrix.android.sdk.api.auth.data.LoginFlowTypes
import org.matrix.android.sdk.api.auth.registration.RegistrationFlowResponse
import org.matrix.android.sdk.api.auth.registration.nextUncompletedStage
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.extensions.orTrue
import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.raw.RawService
Expand Down Expand Up @@ -92,8 +92,9 @@ class BootstrapSharedViewModel @AssistedInject constructor(
val wellKnown = rawService.getElementWellknown(session.sessionParams)
setState {
copy(
isSecureBackupRequired = wellKnown?.isSecureBackupRequired().orFalse(),
secureBackupMethod = wellKnown?.secureBackupMethod() ?: SecureBackupMethod.KEY_OR_PASSPHRASE,
// Tchap: force to configure secure backup key even if well-known is null
isSecureBackupRequired = wellKnown?.isSecureBackupRequired().orTrue(),
secureBackupMethod = wellKnown?.secureBackupMethod() ?: SecureBackupMethod.KEY,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.Matrix
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.extensions.orTrue
import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.api.raw.RawService
import org.matrix.android.sdk.api.session.Session
Expand Down Expand Up @@ -142,7 +142,7 @@ class SelfVerificationViewModel @AssistedInject constructor(
viewModelScope.launch(Dispatchers.IO) {
val wellKnown = rawService.getElementWellknown(session.sessionParams)
setState {
copy(isVerificationRequired = wellKnown?.isSecureBackupRequired().orFalse())
copy(isVerificationRequired = wellKnown?.isSecureBackupRequired().orTrue()) // Tchap: force to configure secure backup even if well-known is null
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import org.matrix.android.sdk.api.auth.UserPasswordAuth
import org.matrix.android.sdk.api.auth.data.LoginFlowTypes
import org.matrix.android.sdk.api.auth.registration.RegistrationFlowResponse
import org.matrix.android.sdk.api.auth.registration.nextUncompletedStage
import org.matrix.android.sdk.api.extensions.orTrue
import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.api.raw.RawService
import org.matrix.android.sdk.api.session.crypto.crosssigning.CrossSigningService
Expand Down Expand Up @@ -391,7 +392,7 @@ class HomeActivityViewModel @AssistedInject constructor(

private fun sessionHasBeenUnverified(elementWellKnown: ElementWellKnown?) {
val session = activeSessionHolder.getSafeActiveSession() ?: return
val isSecureBackupRequired = elementWellKnown?.isSecureBackupRequired() ?: false
val isSecureBackupRequired = elementWellKnown?.isSecureBackupRequired().orTrue() // Tchap: force to configure secure backup even if well-known is null
if (isSecureBackupRequired) {
// If 4S is forced, force verification
// for stability cancel all pending verifications?
Expand Down Expand Up @@ -425,7 +426,7 @@ class HomeActivityViewModel @AssistedInject constructor(
}

val elementWellKnown = rawService.getElementWellknown(session.sessionParams)
val isSecureBackupRequired = elementWellKnown?.isSecureBackupRequired() ?: false
val isSecureBackupRequired = elementWellKnown?.isSecureBackupRequired().orTrue() // Tchap: force to configure secure backup even if well-known is null

// In case of account creation, it is already done before
if (initialState.authenticationDescription is AuthenticationDescription.Register) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ data class E2EWellKnownConfig(
val e2eDefault: Boolean? = null,

@Json(name = "secure_backup_required")
val secureBackupRequired: Boolean? = null,
val secureBackupRequired: Boolean? = true, // Tchap: force to configure secure backup even if well-known is empty

/**
* The new field secure_backup_setup_methods is an array listing the methods the client should display.
Expand All @@ -65,7 +65,7 @@ data class E2EWellKnownConfig(
* clients should fallback to the default value of: ["key", "passphrase"].
*/
@Json(name = "secure_backup_setup_methods")
val secureBackupSetupMethods: List<String>? = null,
val secureBackupSetupMethods: List<String>? = listOf("key"), // Tchap: force to configure secure backup even if well-known is empty

/**
* Configuration for sharing keys strategy which should be used instead of [im.vector.app.config.Config.KEY_SHARING_STRATEGY].
Expand Down

0 comments on commit 84cfc4c

Please sign in to comment.