mogol / flutter_secure_storage

A Flutter plugin to store data in secure storage
https://pub.dartlang.org/packages/flutter_secure_storage
BSD 3-Clause "New" or "Revised" License
1.12k stars 367 forks source link

`deleteAll` not working on iOS #720

Closed feinstein closed 4 months ago

feinstein commented 4 months ago

I updated from version 9.0.0 to 9.2.1, and now deleteAll stopped working.

I had this code in my app's initialization:

 Future<void> init() async {
    final isFirstRun = sharedPreferences.getBool(StorageKey.isFirstRun.name) ?? true;

    // iOS Keychain keeps data stored by the app even if the user removed the app.
    // This can cause undesired behavior where the user gets old data, even after
    // uninstalling/reinstalling the app.
    if (isFirstRun) {
      await secureStorage.deleteAll();
      await sharedPreferences.setBool(StorageKey.isFirstRun.name, false);
    }

It checks if this is the first time the app runs, and if positive it deletes all entries (as keychain keeps it's values across installations).

This code used to work just fine, but now it doesn't work any more.

techouse commented 4 months ago

@feinstein I've created a PR #719 that fixes this.

Can you please see if it works for you? 😇🙏 Put this in your pubspec.yaml

dependencies:
  flutter_secure_storage: ^9.2.1

dependency_overrides:
  flutter_secure_storage:
    git:
      url: https://github.com/techouse/flutter_secure_storage.git
      ref: fix/read-all
      path: flutter_secure_storage
  flutter_secure_storage_macos:
    git:
      url: https://github.com/techouse/flutter_secure_storage.git
      ref: fix/read-all
      path: flutter_secure_storage_macos
feinstein commented 4 months ago

@techouse it works, thanks!

juliansteenbakker commented 4 months ago

I have released v9.2.2 with this fix