Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Lockwise keychain launch issues #1192

Merged
merged 7 commits into from
Feb 12, 2020
Merged

Conversation

kaylagalway
Copy link
Contributor

Fixes #1190

  • Change was made in PR 1178 that erased entire Keychain instead of specific values when a user logged out. This PR makes a change that specifies when to erase user sync account values and local database values. This resolves lockwise being unusable after logging out and back in.

To test:

  • Launch lockwise with fresh install
  • Log in to sync account, verify sync is successful
  • Log out of sync account
  • Log in to sync account, verify sync is successful
  • Force quit app
  • Relaunch app and app should continue to sync normally

@kaylagalway kaylagalway requested a review from a team as a code owner February 10, 2020 20:14
Copy link
Contributor

@jhugman jhugman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I very much like the approach you have here.

In the cases where you are wiping both .account and .database, I would recommend either an .all case, or just wiping the keychain as before.

Excellent work.

@@ -109,7 +109,7 @@ class BaseDataStore {
}()

internal var loginsKey: String? {
let key = "sqlcipher.key.logins.db"
let key = KeychainKey.loginsKey.rawValue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😸

@@ -25,7 +25,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, willFinishLaunchingWithOptions
launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
if isFirstRun {
KeychainWrapper.wipeKeychain()
KeychainWrapper.sharedAppContainerKeychain.clearAllValues(for: .account)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUIC, we should be able to clear values for .database here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

@@ -142,7 +142,7 @@ extension AccountStore {
}

private func clear() {
KeychainWrapper.wipeKeychain()
keychainWrapper.clearAllValues(for: .account)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC This is the point which fixes the bug.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes 👍

@@ -107,7 +107,8 @@ extension AppDelegate {
} else if previous > current {
//this would mean a user had an upgraded test version and has now downgraded to a previous version
//we should wipe keychain data to remove any possible abnormalities
KeychainWrapper.wipeKeychain()
KeychainWrapper.sharedAppContainerKeychain.clearAllValues(for: .account)
KeychainWrapper.sharedAppContainerKeychain.clearAllValues(for: .database)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In time, will we move back to wipeKeychain()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I like being explicit about the values for now, but I think in the future we could do this.

@kaylagalway kaylagalway changed the title Lockwise launch issues 1190 Lockwise keychain launch issues Feb 10, 2020
@kaylagalway
Copy link
Contributor Author

I very much like the approach you have here.

In the cases where you are wiping both .account and .database, I would recommend either an .all case, or just wiping the keychain as before.

Excellent work.

Agreed - I will add a .all case!

@kaylagalway kaylagalway merged commit d14e787 into master Feb 12, 2020
@kaylagalway kaylagalway deleted the lockwise-launch-issues-1190 branch February 18, 2020 21:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lockwise is unusable after following the STR
2 participants