flutter_secure_storage icon indicating copy to clipboard operation
flutter_secure_storage copied to clipboard

[bug] [macOS]: Asks for confidential information stored in keychain multiple times even after pressing "Always Allow"

Open KristijanMitrik opened this issue 2 years ago • 5 comments

KristijanMitrik avatar Jul 20 '23 12:07 KristijanMitrik

This is pretty annoying, to the point where we have to combine all secure information into one key and read/write it only once.

bvoq avatar Jul 31 '23 11:07 bvoq

@bvoq Do you know what might be the problem?

KristijanMitrik avatar Aug 03 '23 10:08 KristijanMitrik

Yes, you need to use only one key. I think it prompts the password for each key you use. Luckily Keychain supports 16MB per key.

bvoq avatar Aug 04 '23 09:08 bvoq

And use the following options when initialising your keychain:

const MacOsOptions kFlutterSecureStorageMacOSOptions = MacOsOptions(
  accessibility: KeychainAccessibility.unlocked_this_device,
  groupId: null,
  // Note: This needs to be true in order for macOS to only write to the Local Items (or Cloud Items) keychain.
  synchronizable: true,
);

See also: https://github.com/mogol/flutter_secure_storage/issues/573

bvoq avatar Aug 04 '23 09:08 bvoq

You can debug your application by opening keychain and looking for flutter_secure_storage: image

Delete all previous keys there. I noticed that for some reason, if you set synchronizable to false, it writes first to 'Local Items' keychain (or 'iCloud Items' keychain if enabled) and then keeps writing to login keychain instead. With synchronizable: true, the behaviour is more normal. And add the keychain sharing capability to your xcode project.

bvoq avatar Aug 04 '23 09:08 bvoq

I am closing all older issues. If this issue still exists in the latest version, please let me know.

juliansteenbakker avatar Aug 13 '24 20:08 juliansteenbakker