搜尋套件、儲存庫與 APP 分類

套件詳情v2.2.0

flutter_locker

使用生物辨識認證(指紋、Touch ID、Face ID...)在金鑰串中保護您的秘密

AndroidiOS
近 30 天下載
4000
喜歡數
50
Pub 分數
160

安裝套件

flutter pub add flutter_locker

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Flutter Locker 是一個安全的套件,使用平台特定的金鑰串並結合生物識別驗證(指紋、Touch ID、Face ID)來儲存和檢索敏感資料。它利用 Android 和 iOS 的原生安全功能來保護 API 金鑰或權杖等機密資訊。此套件確保資料始終處於加密狀態,並且僅在成功通過生物識別驗證後才可存取,從而提升應用程式安全性,同時不影響使用者體驗。非常適合需要高安全性本機儲存的應用程式。

適用情境

  • 安全儲存 API 金鑰
  • 保護用戶憑證
  • 啟用生物識別存取敏感資料
  • 將加密密鑰本地儲存
  • 實現安全的會話管理

主要特色

  • 生物識別認證整合
  • 平台原生密鑰鏈使用
  • 加密本機儲存
  • 用於安全存取的簡單 API
  • 如果生物識別失敗,自動回退到密碼

適合對象

  • 處理敏感用戶數據的應用程式
  • 金融或醫療應用
  • 認證密集型應用
  • 需要安全本地儲存的應用程式
  • 注重用戶隱私的開發者

使用建議

  • 需要生物識別硬體支援
  • 僅限 Android 和 iOS 平台
  • 可能需要額外的權限處理
  • 不適用於非生物特徵環境
  • 依賴於底層作業系統安全機制

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Flutter Locker🔒

Locker

Flutter plugin that secures your secrets in keychain using biometric authentication (Fingerprint, Touch ID, Face ID...).

It uses:

Table of contents

Migrate to 2.1.0

The models now accept named parameters instead of unnamed, e.g.:

RetrieveSecretRequest(
  key: 'key',
  androidPrompt: AndroidPrompt(title: 'title', cancelLabel: 'cancel'),
  iOsPrompt: IOsPrompt(touchIdText: 'description'),
)

Usage

FlutterLocker.supportsBiometricAuthentication();

Checks if the devices has biometric capabilities no matter if they are configured and turned on.

FlutterLocker.canAuthenticate();

Checks if the devices has biometric capabilities that are configured and turned on.

await FlutterLocker.save(SaveSecretRequest(
  key: 'key',
  secret: 'secret',
  androidPrompt: AndroidPrompt(title: 'Authenticate', cancelLabel: 'Cancel'),
));

Saves the secret. On Android prompt is shown, while on iOS there is no need for the prompt when saving.

await FlutterLocker.retrieve(RetrieveSecretRequest(
  key: key,
  androidPrompt: AndroidPrompt(title: 'Authenticate', cancelLabel: 'Cancel'),
  iOsPrompt: IOsPrompt(touchIdText: 'Authenticate'),
));

Retrieves the secret. You need to provide a prompt for Android and iOS. Prompt for iOS is used only with TouchID. FaceID uses strings from Info.plist.

await FlutterLocker.delete('key');

Deletes the secret.

Exceptions

For common exceptions, a LockerException is thrown.

Use LockerException.reason to find out what went wrong:

  • secretNotFound - Happens when you try to retrieve a secret that was never saved for that key
  • authenticationCanceled - User canceled the authentication prompt
  • authenticationFailed - User failed authentication, e.g. by too many wrong attempts

For other exception, a PlatformException is thrown. You can use PlatformException.message to get more info.

Notes

  • iOS only: app will not show authentication dialog when saving (authentication will always succeed)
  • please follow Locker and Goldfinger setup to prevent any issues

Setup

iOS

To use Locker you need to add the NSFaceIDUsageDescription to you Info.plist.

If NSFaceIDUsageDescription is not provided, the app will crash with the following error:

This app has crashed because it attempted to access privacy-sensitive data without a usage description.  The app's Info.plist must contain an NSFaceIDUsageDescription key with a string value explaining to the user how the app uses this data.
Android

Ensure MainActivity extends FlutterFragmentActivity.

class MainActivity: FlutterFragmentActivity() {
    // ...
}

When showing authentication prompt, the app might crash on some Samsung devices if you don't use an appropriate theme: https://github.com/infinum/flutter-plugins-locker/commit/fcb1f6401d89f860d24ea9a75027d62a03e87926.

Contributing

We believe that the community can help us improve and build better a product. Please refer to our contributing guide to learn about the types of contributions we accept and the process for submitting them.

To ensure that our community remains respectful and professional, we defined a code of conduct that we expect all contributors to follow.

We appreciate your interest and look forward to your contributions.

License

Copyright 2024 Infinum

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Credits

Maintained and sponsored by Infinum.

所屬分類

原始碼儲存庫

使用此套件的專案