Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide confirm message as not needed at point of sign in #6934

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Riot/Assets/en.lproj/Vector.strings
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
"authentication_qr_login_failure_invalid_qr" = "QR code is invalid.";
"authentication_qr_login_failure_request_denied" = "The request was denied on the other device.";
"authentication_qr_login_failure_request_timed_out" = "The linking wasn’t completed in the required time.";
"authentication_qr_login_failure_e2ee_security_error" = "A security issue was encountered setting up secure messaging. One of the following may be compromised: Your homeserver; Your internet connection(s); Your device(s);";
"authentication_qr_login_failure_retry" = "Try again";

// MARK: Password Validation
Expand Down
4 changes: 4 additions & 0 deletions Riot/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,10 @@ public class VectorL10n: NSObject {
public static var authenticationQrLoginDisplayTitle: String {
return VectorL10n.tr("Vector", "authentication_qr_login_display_title")
}
/// A security issue was encountered setting up secure messaging. One of the following may be compromised: Your homeserver; Your internet connection(s); Your device(s);
public static var authenticationQrLoginFailureE2eeSecurityError: String {
return VectorL10n.tr("Vector", "authentication_qr_login_failure_e2ee_security_error")
}
/// QR code is invalid.
public static var authenticationQrLoginFailureInvalidQr: String {
return VectorL10n.tr("Vector", "authentication_qr_login_failure_invalid_qr")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ struct QRLoginRendezvousPayload: Codable {
case success
case declined
case verified
case e2eeSecurityError = "e2ee_security_error"
}

// swiftformat:disable:next redundantBackticks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,34 @@ class QRLoginService: NSObject, QRLoginServiceProtocol {
return
}

// check that device key from verifier matches the one received from the homeserver
guard let verifyingDeviceInfo = session.crypto.device(withDeviceId: verifiyingDeviceId, ofUser: session.myUserId),
verifyingDeviceInfo.fingerprint == verifyingDeviceKey else {
MXLog.error("[QRLoginService] Received invalid verifying device info")

// try informing the other party of a potential E2EE issue
if let requestData = try? JSONEncoder().encode(QRLoginRendezvousPayload(type: .loginFinish, outcome: .e2eeSecurityError)) {
_ = await rendezvousService.send(data: requestData)
}

await teardownRendezvous(state: .failed(error: .e2eeSecurityError))
return
}

MXLog.debug("[QRLoginService] Received cross-signing details \(responsePayload)")

if let masterKeyFromVerifyingDevice = responsePayload.masterKey,
let localMasterKey = session.crypto.crossSigningKeys(forUser: session.myUserId).masterKeys?.keys {
// if master key was received from verifier then check that it matches the one from the homeserver
guard masterKeyFromVerifyingDevice == localMasterKey else {
MXLog.error("[QRLoginService] Received invalid master key from verifying device")
await teardownRendezvous(state: .failed(error: .rendezvousFailed))

// try informing the other party of a potential E2EE issue
if let requestData = try? JSONEncoder().encode(QRLoginRendezvousPayload(type: .loginFinish, outcome: .e2eeSecurityError)) {
_ = await rendezvousService.send(data: requestData)
}

await teardownRendezvous(state: .failed(error: .e2eeSecurityError))
return
}

Expand All @@ -311,18 +332,13 @@ class QRLoginService: NSObject, QRLoginServiceProtocol {

guard mskVerificationResult == true else {
MXLog.error("[QRLoginService] Failed marking the master key as trusted")
await teardownRendezvous(state: .failed(error: .rendezvousFailed))
await teardownRendezvous(state: .failed(error: .e2eeSecurityError))
return
}
}

guard let verifyingDeviceInfo = session.crypto.device(withDeviceId: verifiyingDeviceId, ofUser: session.myUserId),
verifyingDeviceInfo.fingerprint == verifyingDeviceKey else {
MXLog.error("[QRLoginService] Received invalid verifying device info")
await teardownRendezvous(state: .failed(error: .rendezvousFailed))
return
}


// we only mark the verifying device as trusted if the device key matches and the master key matches (or the
// master key was not sent)
MXLog.debug("[QRLoginService] Locally marking the existing device as verified \(verifyingDeviceInfo)")
await withCheckedContinuation { (continuation: CheckedContinuation<Void, Never>) in
session.crypto.setDeviceVerification(.verified, forDevice: verifiyingDeviceId, ofUser: session.myUserId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ enum QRLoginServiceError: Error, Equatable {
case requestDenied
case requestTimedOut
case rendezvousFailed
case e2eeSecurityError
}

// MARK: - QRLoginServiceState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,17 @@ struct AuthenticationQRLoginConfirmScreen: View {
/// The screen's footer.
var footerContent: some View {
VStack(spacing: 16) {
Text(VectorL10n.authenticationQrLoginConfirmAlert)
.padding(10)
.multilineTextAlignment(.center)
.font(theme.fonts.body)
.foregroundColor(theme.colors.alert)
.shapedBorder(color: theme.colors.alert, borderWidth: 1, shape: RoundedRectangle(cornerRadius: 8))
.fixedSize(horizontal: false, vertical: true)
.padding(.bottom, 12)
.accessibilityIdentifier("alertText")

// These are only applicable to reciprocating a login via QR which isn't yet implemented:
//
// Text(VectorL10n.authenticationQrLoginConfirmAlert)
// .padding(10)
// .multilineTextAlignment(.center)
// .font(theme.fonts.body)
// .foregroundColor(theme.colors.alert)
// .shapedBorder(color: theme.colors.alert, borderWidth: 1, shape: RoundedRectangle(cornerRadius: 8))
// .fixedSize(horizontal: false, vertical: true)
// .padding(.bottom, 12)
// .accessibilityIdentifier("alertText")
// Button(action: confirm) {
// Text(VectorL10n.confirm)
// }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class AuthenticationQRLoginFailureViewModel: AuthenticationQRLoginFailureViewMod
case .requestTimedOut:
self.state.failureText = VectorL10n.authenticationQrLoginFailureRequestTimedOut
self.state.retryButtonVisible = true
case .e2eeSecurityError:
self.state.failureText = VectorL10n.authenticationQrLoginFailureE2eeSecurityError
self.state.retryButtonVisible = true
default:
break
}
Expand Down