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

Security settings: Improve the SECURE BACKUP section #4434

Merged
merged 21 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c970c07
SecurityViewController: Fix crash
manuroe Jun 15, 2021
7cc653a
Security settings: Display the cross-signing section
manuroe Jun 15, 2021
8b94550
Security settings: Introduce a dynamic section for SECURE BACKUP
manuroe Jun 15, 2021
110879b
Secure backup: Allow to execute a random closure the secure backup is…
manuroe Jun 16, 2021
ccf5735
Key Backup setup: Create the key backup using 4S if it exists
manuroe Jun 16, 2021
b84ea2b
Security settings: Add an option to reset the secure backup
manuroe Jun 16, 2021
82639fc
Security settings: Offer to reset the secure backup when there is no …
manuroe Jun 16, 2021
5d526fd
Security settings: Display section description at the bottom
manuroe Jun 16, 2021
ed7eb4e
Security settings: Manage the case when there is no secure backup
manuroe Jun 16, 2021
13375a5
Security settings: Use the same wording as element web for the secure…
manuroe Jun 16, 2021
115c65c
Security settings: Manage the case where the is a key backup but no s…
manuroe Jun 16, 2021
e68c465
Security settings: Improve the state of the secure backup section to…
manuroe Jun 16, 2021
a27dc11
Security settings: Reduce the number of secure backup section states
manuroe Jun 16, 2021
83f6a01
Forgot to push this change. Thanks CI.
manuroe Jun 16, 2021
71ea0f8
Fix build without compilation flag
manuroe Jun 16, 2021
838558a
Valide the 4S private key before using it
manuroe Jun 16, 2021
26ea4fc
Wording: Replace Recovery Passphrase and Recovery Key by Security Phr…
manuroe Jun 16, 2021
5e360b9
CHANGES
manuroe Jun 16, 2021
eb06b6f
Cleaning
manuroe Jun 16, 2021
3b180fc
More cleaning
manuroe Jun 16, 2021
664eb02
Merge branch 'develop' into manu/4430_security_settings_update
manuroe Jun 17, 2021
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
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Changes to be released in next version
* Integrated FLEX for debug builds.
* VoIP: Add dial pad for PSTN capable servers to menu on homescreen.
* VoIP: Replace call bar with PiP tiles for every type of calls.
* Security settings: Display the cross-signing section (#4430).
* Security settings: The Secure backup section has been updated to match element-web UX (#4430).
* Wording: Replace Recovery Passphrase and Recovery Key by Security Phrase and Security Key (#4268).

🐛 Bugfix
* StartChatViewController: Add more helpful message when trying to start DM with a user that does not exist (#224).
Expand Down
108 changes: 58 additions & 50 deletions Riot/Assets/en.lproj/Vector.strings

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Riot/Generated/Storyboards.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ internal enum StoryboardScene {

internal static let initialScene = InitialSceneType<Riot.KeyBackupSetupSuccessFromRecoveryKeyViewController>(storyboard: KeyBackupSetupSuccessFromRecoveryKeyViewController.self)
}
internal enum KeyBackupSetupSuccessFromSecureBackupViewController: StoryboardType {
internal static let storyboardName = "KeyBackupSetupSuccessFromSecureBackupViewController"

internal static let initialScene = InitialSceneType<Riot.KeyBackupSetupSuccessFromSecureBackupViewController>(storyboard: KeyBackupSetupSuccessFromSecureBackupViewController.self)
}
internal enum KeyVerificationDataLoadingViewController: StoryboardType {
internal static let storyboardName = "KeyVerificationDataLoadingViewController"

Expand Down
128 changes: 76 additions & 52 deletions Riot/Generated/Strings.swift

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Riot/Modules/Home/HomeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ - (CrossSigningSetupBannerCell *)keyVerificationSetupBannerPrototypeCell

- (void)presentSecureBackupSetup
{
SecureBackupSetupCoordinatorBridgePresenter *keyBackupSetupCoordinatorBridgePresenter = [[SecureBackupSetupCoordinatorBridgePresenter alloc] initWithSession:self.mainSession];
SecureBackupSetupCoordinatorBridgePresenter *keyBackupSetupCoordinatorBridgePresenter = [[SecureBackupSetupCoordinatorBridgePresenter alloc] initWithSession:self.mainSession allowOverwrite:NO];
keyBackupSetupCoordinatorBridgePresenter.delegate = self;

[keyBackupSetupCoordinatorBridgePresenter presentFrom:self animated:YES];
Expand Down
73 changes: 68 additions & 5 deletions Riot/Modules/KeyBackup/Setup/KeyBackupSetupCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ final class KeyBackupSetupCoordinator: KeyBackupSetupCoordinatorType {
// MARK: - Public methods

func start() {

// Set key backup setup intro as root controller
let keyBackupSetupIntroViewController = self.createSetupIntroViewController()
keyBackupSetupIntroViewController.delegate = self
self.navigationRouter.setRootModule(keyBackupSetupIntroViewController)
if self.session.crypto.recoveryService.hasRecovery() {
showUnlockSecureBackup()
} else {
showSetupIntro()
}
}

func toPresentable() -> UIViewController {
Expand All @@ -57,6 +57,13 @@ final class KeyBackupSetupCoordinator: KeyBackupSetupCoordinatorType {

// MARK: - Private methods

private func showSetupIntro() {
// Set key backup setup intro as root controller
let keyBackupSetupIntroViewController = self.createSetupIntroViewController()
keyBackupSetupIntroViewController.delegate = self
self.navigationRouter.setRootModule(keyBackupSetupIntroViewController)
}

private func createSetupIntroViewController() -> KeyBackupSetupIntroViewController {

let backupState = self.session.crypto.backup?.state ?? MXKeyBackupStateUnknown
Expand All @@ -80,6 +87,17 @@ final class KeyBackupSetupCoordinator: KeyBackupSetupCoordinatorType {
return KeyBackupSetupIntroViewController.instantiate(isABackupAlreadyExists: isABackupAlreadyExists, encryptionKeysExportPresenter: encryptionKeysExportPresenter)
}

private func showUnlockSecureBackup() {
let recoveryGoal: SecretsRecoveryGoal = .unlockSecureBackup { (privateKey, completion) in
self.createKeyBackupUsingSecureBackup(privateKey: privateKey, completion: completion)
}

let coordinator = SecretsRecoveryCoordinator(session: self.session, recoveryMode: .passphraseOrKey, recoveryGoal: recoveryGoal, navigationRouter: self.navigationRouter)
coordinator.delegate = self
coordinator.start()
self.add(childCoordinator: coordinator)
}

private func showSetupPassphrase(animated: Bool) {
let keyBackupSetupPassphraseCoordinator = KeyBackupSetupPassphraseCoordinator(session: self.session)
keyBackupSetupPassphraseCoordinator.delegate = self
Expand All @@ -104,6 +122,33 @@ final class KeyBackupSetupCoordinator: KeyBackupSetupCoordinatorType {
viewController.delegate = self
self.navigationRouter.push(viewController, animated: animated, popCompletion: nil)
}

private func showSetupWithSecureBackupSuccess(animated: Bool) {
let viewController = KeyBackupSetupSuccessFromSecureBackupViewController.instantiate()
viewController.delegate = self
self.navigationRouter.push(viewController, animated: animated, popCompletion: nil)
}

private func createKeyBackupUsingSecureBackup(privateKey: Data, completion: @escaping (Result<Void, Error>) -> Void) {
guard let keyBackup = session.crypto.backup, let recoveryService = session.crypto.recoveryService else {
return
}

keyBackup.prepareKeyBackupVersion(withPassword: nil, success: { megolmBackupCreationInfo in
keyBackup.createKeyBackupVersion(megolmBackupCreationInfo, success: { _ in
recoveryService.updateRecovery(forSecrets: [MXSecretId.keyBackup.takeUnretainedValue() as String], withPrivateKey: privateKey) {
completion(.success(Void()))
} failure: { error in
completion(.failure(error))
}

}, failure: { error in
completion(.failure(error))
})
}, failure: { error in
completion(.failure(error))
})
}
}

// MARK: - KeyBackupSetupIntroViewControllerDelegate
Expand Down Expand Up @@ -133,6 +178,17 @@ extension KeyBackupSetupCoordinator: KeyBackupSetupPassphraseCoordinatorDelegate
}
}

// MARK: - SecretsRecoveryCoordinatorDelegate
extension KeyBackupSetupCoordinator: SecretsRecoveryCoordinatorDelegate {
func secretsRecoveryCoordinatorDidRecover(_ coordinator: SecretsRecoveryCoordinatorType) {
self.showSetupWithSecureBackupSuccess(animated: true)
}

func secretsRecoveryCoordinatorDidCancel(_ coordinator: SecretsRecoveryCoordinatorType) {
self.delegate?.keyBackupSetupCoordinatorDidCancel(self)
}
}

// MARK: - KeyBackupSetupSuccessFromPassphraseViewControllerDelegate
extension KeyBackupSetupCoordinator: KeyBackupSetupSuccessFromPassphraseViewControllerDelegate {
func keyBackupSetupSuccessFromPassphraseViewControllerDidTapDoneAction(_ viewController: KeyBackupSetupSuccessFromPassphraseViewController) {
Expand All @@ -146,3 +202,10 @@ extension KeyBackupSetupCoordinator: KeyBackupSetupSuccessFromRecoveryKeyViewCon
self.delegate?.keyBackupSetupCoordinatorDidSetupRecoveryKey(self)
}
}

// MARK: - KeyBackupSetupSuccessFromSecureBackupViewControllerDelegate
extension KeyBackupSetupCoordinator: KeyBackupSetupSuccessFromSecureBackupViewControllerDelegate {
func keyBackupSetupSuccessFromSecureBackupViewControllerDidTapDoneAction(_ viewController: KeyBackupSetupSuccessFromSecureBackupViewController) {
self.delegate?.keyBackupSetupCoordinatorDidSetupRecoveryKey(self)
}
}
Loading