搜索插件、代码仓与 APP 分类

插件详情v2.2.0

flutter_locker

使用生物识别认证(指纹、触控 ID、面容 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.

所属分类

源码仓库

使用此插件的项目