-
Notifications
You must be signed in to change notification settings - Fork 611
Add Flutter Secure Storage extension
#6001
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
Conversation
- add flet-secure-storage module to project configuration files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've reviewed this pull request using the Sourcery rules engine
|
@FeodorFitsner I used |
|
I tested this on Windows and Web, and I will test it on Linux and Android soon.
|
We use |
| } else { | ||
| throw Exception("Add operation can be applied to lists or maps: $op"); | ||
| } | ||
| if (shouldNotify) node.control.notify(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What did the changes in control.dart fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was getting an exception from line 378 when calling the .readAll method, which returns a map. When I deleted something from storage, I got the same error. This means that at runtime I'm working with a map, while control.dart expects to work only with a list.
These changes make it possible to work with a map at runtime, which is what FlutterSecureStorage actually uses.
|
Every new service/control package requires these additional "parts":
|
...ckages/flet-secure-storage/src/flutter/flet_secure_storage/lib/src/utils/secure_storage.dart
Outdated
Show resolved
Hide resolved
...hon/packages/flet-secure-storage/src/flutter/flet_secure_storage/lib/src/secure_storage.dart
Outdated
Show resolved
Hide resolved
|
I've dropped a few comments - hope it's OK :). Otherwise, solid work - great contribution! |
|
Got this while running on macOS and trying to set a key/value: Trying to add to entitlements gives me another error building macOS client app: 😬 |
|
OK, I'm going to test on iOS. For macOS we will implement #2347. |
- manage the secure storage subscription lifecycle via `_updateListeners()` - refactored code and organized configuration files - removed unused code (`createSecureStorage()`, `parseDateTime()`) - replaced `T | None` type annotations with `Optional[]`
I suspect this is related to the macOS environment setup: There’s also some related information here that might be helpful: |
- added Android biometric demo - configured WebOptions for secure storage - updated enums with more descriptive names - added USE_BIOMETRIC and USE_FINGERPRINT permissions to AndroidManifest
|
Thank you for the update! Now, as we have doc page for secure storage I'd add more about supported platforms (example) and, most importantly, configuration requirements. Like you added two permissions here - I think it's worth mentioning for Android that "in order to use this ... you have to add that" (here) into your [tool.flet.android.permission]
"android.permission.USE_BIOMETRIC" = true
"android.permission.USE_FINGERPRINT" = trueWe have a mechanism for that.
[tool.flet.android.manifest_application]
"allowBackup" = "false"
"fullBackupContent" = "false"There are also configuration requirements for Linux ( All in all - great job, thanks for bearing with me! |
|
I was just about to write to you to say thank you :) I should mention that I haven’t been able to properly test this on Linux yet. I’m using WSL for that and ran into several issues. However, I did test it on Android and attached a video to the main post -- it works perfectly there! |
- added secure_storage docs folder with usage and API reference - removed old options file; moved classes to types.py - fixed availability event: now fires on available instead of is_available_storage - added documentation for SecureStorageEvent
ndonkoHenri
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution!
I haven't tested it yet, but looks great.
I added some comments. I hope they dont feel too much. Feel free to let know if one or more are not comprehensive enough, or if you won't have time to work on (in which case I could pickup sometime later).
sdk/python/packages/flet-secure-storage/src/flet_secure_storage/options.py
Outdated
Show resolved
Hide resolved
sdk/python/packages/flet-secure-storage/src/flet_secure_storage/types.py
Outdated
Show resolved
Hide resolved
sdk/python/packages/flet-secure-storage/src/flet_secure_storage/options.py
Outdated
Show resolved
Hide resolved
sdk/python/packages/flet-secure-storage/src/flet_secure_storage/secure_storage.py
Show resolved
Hide resolved
...ckages/flet-secure-storage/src/flutter/flet_secure_storage/lib/src/utils/secure_storage.dart
Outdated
Show resolved
Hide resolved
sdk/python/packages/flet-secure-storage/src/flet_secure_storage/options.py
Outdated
Show resolved
Hide resolved
sdk/python/packages/flet-secure-storage/src/flet_secure_storage/types.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a new flet-secure-storage extension that provides secure storage functionality across multiple platforms (iOS, Android, web, Windows, macOS, and Linux). On iOS it uses Keychain, and on Android it uses encrypted shared preferences powered by Tink.
Changes:
- Added new
flet-secure-storagePython package with cross-platform secure storage APIs - Integrated the extension into the Flet client and SDK dependencies
- Enhanced control patch operations to support both lists and maps (previously only lists)
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/python/pyproject.toml | Added flet-secure-storage to workspace dependencies and isort configuration |
| sdk/python/packages/flet/pyproject.toml | Added flet-secure-storage to extensions list |
| sdk/python/packages/flet/mkdocs.yml | Added SecureStorage to services documentation navigation |
| sdk/python/packages/flet/docs/services/securestorage.md | Created documentation page for SecureStorage service |
| sdk/python/packages/flet/docs/extend/built-in-extensions.md | Listed flet-secure-storage as a built-in extension |
| sdk/python/packages/flet-secure-storage/src/flutter/flet_secure_storage/pubspec.yaml | Defined Flutter package dependencies and metadata |
| sdk/python/packages/flet-secure-storage/src/flutter/flet_secure_storage/lib/src/utils/secure_storage.dart | Implemented parsing utilities for platform-specific options |
| sdk/python/packages/flet-secure-storage/src/flutter/flet_secure_storage/lib/src/secure_storage.dart | Implemented core SecureStorageService with CRUD operations |
| sdk/python/packages/flet-secure-storage/src/flutter/flet_secure_storage/lib/src/extension.dart | Registered SecureStorage as a Flet service |
| sdk/python/packages/flet-secure-storage/src/flutter/flet_secure_storage/lib/flet_secure_storage.dart | Exported extension for Flutter integration |
| sdk/python/packages/flet-secure-storage/src/flet_secure_storage/types.py | Defined enums and event types for secure storage |
| sdk/python/packages/flet-secure-storage/src/flet_secure_storage/secure_storage.py | Implemented Python SecureStorage service class with async methods |
| sdk/python/packages/flet-secure-storage/src/flet_secure_storage/options.py | Defined platform-specific configuration classes |
| sdk/python/packages/flet-secure-storage/src/flet_secure_storage/init.py | Exposed public API exports |
| sdk/python/packages/flet-secure-storage/pyproject.toml | Configured Python package metadata |
| sdk/python/packages/flet-secure-storage/LICENSE | Added Apache 2.0 license |
| sdk/python/examples/services/secure_storage/basic.py | Provided example demonstrating SecureStorage usage |
| packages/flet/lib/src/models/control.dart | Extended patch operations to support maps in addition to lists |
| client/pubspec.yaml | Added flet_secure_storage dependency to Flet client |
| client/lib/main.dart | Registered flet_secure_storage extension in client |
| client/android/app/src/main/AndroidManifest.xml | Added biometric authentication permissions |
| .github/workflows/ci.yml | Added libsecret dependencies for Linux builds |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sdk/python/packages/flet-secure-storage/src/flet_secure_storage/options.py
Outdated
Show resolved
Hide resolved
sdk/python/packages/flet-secure-storage/src/flet_secure_storage/options.py
Outdated
Show resolved
Hide resolved
sdk/python/packages/flet-secure-storage/src/flet_secure_storage/options.py
Outdated
Show resolved
Hide resolved
...hon/packages/flet-secure-storage/src/flutter/flet_secure_storage/lib/src/secure_storage.dart
Show resolved
Hide resolved
sdk/python/packages/flet-secure-storage/src/flet_secure_storage/secure_storage.py
Show resolved
Hide resolved
sdk/python/packages/flet-secure-storage/src/flet_secure_storage/secure_storage.py
Show resolved
Hide resolved
sdk/python/packages/flet-secure-storage/src/flet_secure_storage/secure_storage.py
Show resolved
Hide resolved
sdk/python/packages/flet-secure-storage/src/flet_secure_storage/secure_storage.py
Show resolved
Hide resolved
sdk/python/packages/flet-secure-storage/src/flet_secure_storage/secure_storage.py
Show resolved
Hide resolved
- added parseAccessControlFlag and updated parsing to return List[AccessControlFlag] - code and documentation refactoring
sdk/python/packages/flet-secure-storage/src/flet_secure_storage/types.py
Outdated
Show resolved
Hide resolved
|
The flutter_secure_storage documentation describes Secure Enclave support for macOS and iOS (see README: https://github.com/juliansteenbakker/flutter_secure_storage/blob/develop/README.md#macos--ios) using the However, in the current version of flutter_secure_storage published on pub.dev, this parameter is not present. As a result, it is also unavailable in the flet-secure-storage extension. For this reason, documentation related to Secure Enclave configuration for macOS/iOS was not added to the Flet documentation, as it does not reflect the current implementation. Possible next steps:
|
That feature seems to be on their dev branch, so it will make sense we wait it lands on master in the future, then we could implement new feature in flet_secure_storage. |
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: TheEthicalBoy <98978078+ndonkoHenri@users.noreply.github.com>
// --FAT_CLIENT_START--
// --RIVE_IMPORT_START--How are these markers used, and how do I know if |
Flet CI builds "normal" and "light" clients for Linux (only), for all other platforms it builds "normal" only. I believe There is a merge conflict right now, so you better fix it. |
|
Sourcery reports a potential command injection, but I believe this is a false positive |
|
It's sad PyPI doesn't have namespaces like npm 🥹 |


Description
This PR adds a new extension implemented as a service that allows storing data securely on the device.
On iOS, it uses Keychain.
On Android, it uses encrypted shared preferences powered by Tink.
This extension is mainly intended for mobile platforms, where it provides fine-grained control over data storage, encryption, and other behavior.
At the same time, it can also be used on web, Windows, macOS, and Linux.
Overall, this extension can be seen as an alternative to SharedPreferences, but with more features and greater control over data handling.
Test Code
Type of change
Checklist
Screenshots
web:

android
android_example.mp4
Additional details
Summary by Sourcery
Introduce a cross-platform secure storage extension and wire it into the Flet client and Python SDK, while extending patch operations to support both list- and map-based structures.
New Features:
Enhancements:
Build:
Documentation: