Merge pull request #1180 from vector-im/feature/complete_security_design_update

Feature/complete security design update
This commit is contained in:
Valere 2020-03-26 14:31:09 +01:00 committed by GitHub
commit 91464a071e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 41 additions and 24 deletions

View File

@ -7,6 +7,7 @@ Features ✨:
Improvements 🙌: Improvements 🙌:
- Verification DM / Handle concurrent .start after .ready (#794) - Verification DM / Handle concurrent .start after .ready (#794)
- Xsigning | Complete security new session design update (#1135)
Bugfix 🐛: Bugfix 🐛:
- Missing avatar/displayname after verification request message (#841) - Missing avatar/displayname after verification request message (#841)

View File

@ -69,7 +69,7 @@ data class VerificationBottomSheetViewState(
class VerificationBottomSheetViewModel @AssistedInject constructor( class VerificationBottomSheetViewModel @AssistedInject constructor(
@Assisted initialState: VerificationBottomSheetViewState, @Assisted initialState: VerificationBottomSheetViewState,
@Assisted args: VerificationBottomSheet.VerificationArgs, @Assisted val args: VerificationBottomSheet.VerificationArgs,
private val session: Session, private val session: Session,
private val supportedVerificationMethodsProvider: SupportedVerificationMethodsProvider) private val supportedVerificationMethodsProvider: SupportedVerificationMethodsProvider)
: VectorViewModel<VerificationBottomSheetViewState, VerificationAction, VerificationBottomSheetViewEvents>(initialState), : VectorViewModel<VerificationBottomSheetViewState, VerificationAction, VerificationBottomSheetViewEvents>(initialState),
@ -142,14 +142,19 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
args: VerificationBottomSheet.VerificationArgs): VerificationBottomSheetViewModel args: VerificationBottomSheet.VerificationArgs): VerificationBottomSheetViewModel
} }
fun queryCancel() = withState { fun queryCancel() = withState { state ->
if (it.userThinkItsNotHim) { if (state.userThinkItsNotHim) {
setState { setState {
copy(userThinkItsNotHim = false) copy(userThinkItsNotHim = false)
} }
} else { } else {
setState { // if the verification is already done you can't cancel anymore
copy(userWantsToCancel = true) if (state.pendingRequest.invoke()?.cancelConclusion != null || state.sasTransactionState is VerificationTxState.TerminalTxState) {
// you cannot cancel anymore
} else {
setState {
copy(userWantsToCancel = true)
}
} }
} }
} }
@ -447,7 +452,10 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
|| pr.localId == state.pendingRequest.invoke()?.localId || pr.localId == state.pendingRequest.invoke()?.localId
|| state.pendingRequest.invoke()?.transactionId == pr.transactionId) { || state.pendingRequest.invoke()?.transactionId == pr.transactionId) {
setState { setState {
copy(pendingRequest = Success(pr)) copy(
transactionId = args.verificationId ?: pr.transactionId,
pendingRequest = Success(pr)
)
} }
} }
} }

View File

@ -16,11 +16,13 @@
package im.vector.riotx.features.crypto.verification.cancel package im.vector.riotx.features.crypto.verification.cancel
import androidx.core.text.toSpannable
import com.airbnb.epoxy.EpoxyController import com.airbnb.epoxy.EpoxyController
import im.vector.riotx.R import im.vector.riotx.R
import im.vector.riotx.core.epoxy.dividerItem import im.vector.riotx.core.epoxy.dividerItem
import im.vector.riotx.core.resources.ColorProvider import im.vector.riotx.core.resources.ColorProvider
import im.vector.riotx.core.resources.StringProvider import im.vector.riotx.core.resources.StringProvider
import im.vector.riotx.core.utils.colorizeMatchingText
import im.vector.riotx.features.crypto.verification.VerificationBottomSheetViewState import im.vector.riotx.features.crypto.verification.VerificationBottomSheetViewState
import im.vector.riotx.features.crypto.verification.epoxy.bottomSheetVerificationActionItem import im.vector.riotx.features.crypto.verification.epoxy.bottomSheetVerificationActionItem
import im.vector.riotx.features.crypto.verification.epoxy.bottomSheetVerificationNoticeItem import im.vector.riotx.features.crypto.verification.epoxy.bottomSheetVerificationNoticeItem
@ -56,9 +58,15 @@ class VerificationCancelController @Inject constructor(
} }
} }
} else { } else {
val otherUserID = state.otherUserMxItem?.id ?: ""
val otherDisplayName = state.otherUserMxItem?.displayName ?: ""
bottomSheetVerificationNoticeItem { bottomSheetVerificationNoticeItem {
id("notice") id("notice")
notice(stringProvider.getString(R.string.verify_cancel_self_verification_from_untrusted)) notice(
stringProvider.getString(R.string.verify_cancel_other, otherDisplayName, otherUserID)
.toSpannable()
.colorizeMatchingText(otherUserID, colorProvider.getColorFromAttribute(R.attr.vctr_notice_text_color))
)
} }
} }

View File

@ -74,15 +74,6 @@ class VerificationRequestController @Inject constructor(
iconColor(colorProvider.getColorFromAttribute(R.attr.riotx_text_primary)) iconColor(colorProvider.getColorFromAttribute(R.attr.riotx_text_primary))
listener { listener?.onClickRecoverFromPassphrase() } listener { listener?.onClickRecoverFromPassphrase() }
} }
bottomSheetVerificationActionItem {
id("skip")
title(stringProvider.getString(R.string.skip))
titleColor(colorProvider.getColor(R.color.riotx_destructive_accent))
// subTitle(stringProvider.getString(R.string.verification_use_passphrase))
iconRes(R.drawable.ic_arrow_right)
iconColor(colorProvider.getColor(R.color.riotx_destructive_accent))
listener { listener?.onClickDismiss() }
}
} else { } else {
val styledText = val styledText =
if (state.isMe) { if (state.isMe) {

View File

@ -29,6 +29,7 @@ import androidx.drawerlayout.widget.DrawerLayout
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import im.vector.matrix.android.api.MatrixCallback import im.vector.matrix.android.api.MatrixCallback
import im.vector.matrix.android.api.session.Session import im.vector.matrix.android.api.session.Session
import im.vector.matrix.android.api.util.toMatrixItem
import im.vector.matrix.android.internal.crypto.model.CryptoDeviceInfo import im.vector.matrix.android.internal.crypto.model.CryptoDeviceInfo
import im.vector.matrix.android.internal.crypto.model.MXUsersDevicesMap import im.vector.matrix.android.internal.crypto.model.MXUsersDevicesMap
import im.vector.riotx.R import im.vector.riotx.R
@ -41,8 +42,8 @@ import im.vector.riotx.core.platform.VectorBaseActivity
import im.vector.riotx.core.pushers.PushersManager import im.vector.riotx.core.pushers.PushersManager
import im.vector.riotx.features.disclaimer.showDisclaimerDialog import im.vector.riotx.features.disclaimer.showDisclaimerDialog
import im.vector.riotx.features.notifications.NotificationDrawerManager import im.vector.riotx.features.notifications.NotificationDrawerManager
import im.vector.riotx.features.popup.DefaultVectorAlert
import im.vector.riotx.features.popup.PopupAlertManager import im.vector.riotx.features.popup.PopupAlertManager
import im.vector.riotx.features.popup.VerificationVectorAlert
import im.vector.riotx.features.rageshake.VectorUncaughtExceptionHandler import im.vector.riotx.features.rageshake.VectorUncaughtExceptionHandler
import im.vector.riotx.features.settings.VectorPreferences import im.vector.riotx.features.settings.VectorPreferences
import im.vector.riotx.features.workers.signout.SignOutViewModel import im.vector.riotx.features.workers.signout.SignOutViewModel
@ -126,6 +127,12 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable {
waiting_view.isVisible = true waiting_view.isVisible = true
} }
}) })
// Ask again if the app is relaunched
if (!sharedActionViewModel.hasDisplayedCompleteSecurityPrompt
&& activeSessionHolder.getSafeActiveSession()?.hasAlreadySynced() == true) {
promptCompleteSecurityIfNeeded()
}
} }
private fun promptCompleteSecurityIfNeeded() { private fun promptCompleteSecurityIfNeeded() {
@ -152,13 +159,14 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable {
// We need to ask // We need to ask
sharedActionViewModel.hasDisplayedCompleteSecurityPrompt = true sharedActionViewModel.hasDisplayedCompleteSecurityPrompt = true
popupAlertManager.postVectorAlert( popupAlertManager.postVectorAlert(
DefaultVectorAlert( VerificationVectorAlert(
uid = "completeSecurity", uid = "completeSecurity",
title = getString(R.string.new_signin), title = getString(R.string.complete_security),
description = getString(R.string.complete_security), description = getString(R.string.crosssigning_verify_this_session),
iconId = R.drawable.ic_shield_warning iconId = R.drawable.ic_shield_warning
).apply { ).apply {
colorInt = ContextCompat.getColor(this@HomeActivity, R.color.riotx_destructive_accent) matrixItem = session.getUser(session.myUserId)?.toMatrixItem()
colorInt = ContextCompat.getColor(this@HomeActivity, R.color.riotx_positive_accent)
contentAction = Runnable { contentAction = Runnable {
(weakCurrentActivity?.get() as? VectorBaseActivity)?.let { (weakCurrentActivity?.get() as? VectorBaseActivity)?.let {
it.navigator.waitSessionVerification(it) it.navigator.waitSessionVerification(it)

View File

@ -2126,7 +2126,7 @@ Not all features in Riot are implemented in RiotX yet. Main missing (and coming
<string name="crosssigning_other_user_not_trust">Other users may not trust it</string> <string name="crosssigning_other_user_not_trust">Other users may not trust it</string>
<string name="complete_security">Complete Security</string> <string name="complete_security">Complete Security</string>
<string name="verification_open_other_to_verify">Open an existing session &amp; use it to verify this one, granting it access to encrypted messages.</string> <string name="verification_open_other_to_verify">Use an existing session to verify this one, granting it access to encrypted messages.</string>
<string name="verification_profile_verify">Verify</string> <string name="verification_profile_verify">Verify</string>
@ -2166,8 +2166,8 @@ Not all features in Riot are implemented in RiotX yet. Main missing (and coming
</plurals> </plurals>
<string name="poll_item_selected_aria">Selected Option</string> <string name="poll_item_selected_aria">Selected Option</string>
<string name="command_description_poll">Creates a simple poll</string> <string name="command_description_poll">Creates a simple poll</string>
<string name="verification_cannot_access_other_session">Cant access an existing session?</string> <string name="verification_cannot_access_other_session">Use a recovery method</string>
<string name="verification_use_passphrase">Use your recovery key or passphrase</string> <string name="verification_use_passphrase">If you cant access an existing session</string>
<string name="new_signin">New Sign In</string> <string name="new_signin">New Sign In</string>

View File

@ -23,6 +23,7 @@
<string name="verify_cancel_self_verification_from_untrusted">If you cancel, you wont be able to read encrypted messages on this device, and other users wont trust it</string> <string name="verify_cancel_self_verification_from_untrusted">If you cancel, you wont be able to read encrypted messages on this device, and other users wont trust it</string>
<string name="verify_cancel_self_verification_from_trusted">If you cancel, you wont be able to read encrypted messages on your new device, and other users wont trust it</string> <string name="verify_cancel_self_verification_from_trusted">If you cancel, you wont be able to read encrypted messages on your new device, and other users wont trust it</string>
<string name="verify_cancel_other">You wont verify %1$s (%2$s) if you cancel now. Start again in their user profile.</string>
<string name="verify_not_me_self_verification"> <string name="verify_not_me_self_verification">
One of the following may be compromised:\n\n- Your password\n- Your homeserver\n- This device, or the other device\n- The internet connection either device is using\n\nWe recommend you change your password &amp; recovery key in Settings immediately. One of the following may be compromised:\n\n- Your password\n- Your homeserver\n- This device, or the other device\n- The internet connection either device is using\n\nWe recommend you change your password &amp; recovery key in Settings immediately.