패키지, 저장소 및 앱 카테고리 검색

패키지 상세v5.0.1

biometric_storage

보안 스토리지: 생체 인식 잠금으로 보호할 수 있는 암호화된 데이터 저장소로, iOS, Android, MacOS를 지원합니다. Linux, Windows 및 웹(localStorage)에 대해서는 부분적으로 지원됩니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
3.7만
좋아요
288
Pub 점수
130

패키지 설치

flutter pub add biometric_storage

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Biometric Storage는 지원되는 플랫폼에서 생체 인증(지문 또는 얼굴 인식)을 선택적으로 제공하는 안전하고 암호화된 데이터 저장 기능을 제공하는 Flutter 패키지입니다. Android 및 iOS에서는 네이티브 보안 기능을 활용하며, 웹(localhost 사용), macOS, Windows, Linux 등 다른 플랫폼에서는 백업 암호화를 제공합니다. 비밀번호나 토큰과 같은 민감한 데이터를 위한 것으로, 장치가 침해되더라도 데이터가 보호되도록 합니다. 개인정보 중심의 로컬 지속성 요구가 있는 앱에 원활하게 통합될 수 있습니다.

사용 사례

  • 보안 비밀번호 저장
  • 인증 토큰 지속성
  • 사용자 선호 암호화
  • 생체 인증 보호 데이터 접근
  • 오프라인 데이터 보호
  • 개인정보 중심 앱 개발

주요 기능

  • 엔드 투 엔드 암호화 저장소
  • 생체 인증 지원
  • 크로스 플랫폼 호환성
  • 암호화된 로컬 저장소로 대체
  • 읽기/쓰기 작업을 위한 간단한 API
  • 플랫폼별 보안 통합

적합한 대상

  • 민감한 사용자 데이터를 처리하는 앱
  • 비밀번호 관리자
  • 보안 노트 앱
  • 인증 시스템
  • 개인정보 보호 중심 애플리케이션
  • 데이터 보안을 우선시하는 개발자

고려 사항

  • 모바일 플랫폼이 아닌 플랫폼에서 생체 인식 지원 제한
  • 웹 버전은 localStorage를 사용합니다(네이티브보다 보안성이 낮음)
  • 적절한 권한 처리가 필요합니다
  • 클라우드 동기화 기능 없음
  • 데스크톱 플랫폼용 추가 설정이 필요할 수 있습니다
  • 기반 운영 체제 보안 메커니즘에 따라 다름

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

biometric_storage

Pub

Encrypted file store, optionally secured by biometric lock for Android, iOS, MacOS and partial support for Linux, Windows and Web.

Meant as a way to store small data in a hardware encrypted fashion. E.g. to store passwords, secret keys, etc. but not massive amounts of data.

  • Android: Uses androidx with KeyStore.
  • iOS and MacOS: LocalAuthentication with KeyChain.
  • Linux: Stores values in Keyring using libsecret. (No biometric authentication support).
  • Windows: Uses wincred.h to read/write into the credential store.
  • Web: Warning Uses unauthenticated, unencrypted storage in localStorage. If you have a better idea for secure storage on web platform, please open an Issue.

Check out AuthPass Password Manager for a app which makes heavy use of this plugin.

Getting Started

Installation
Android

Always required:

  • API Level >= 23 (android/app/build.gradle minSdkVersion 23)

Required only if you actually prompt for authentication, that is, if any storage uses the default authenticationRequired: true. Storage created with authenticationRequired: false never shows a BiometricPrompt, so neither of the following applies to it:

  • MainActivity must extend FlutterFragmentActivity. BiometricPrompt needs a FragmentActivity to host its dialog. If the plugin is attached to a plain FlutterActivity it logs an error and every authenticated read or write fails with AuthError:Failed — unauthenticated storage keeps working.

  • The activity theme must descend from Theme.AppCompat — but only for devices where androidx.biometric falls back to drawing its own fingerprint dialog, which it builds with androidx.appcompat.app.AlertDialog. That fallback is used below API 28, on API 28 devices without a fingerprint sensor, and on a short manufacturer allow-list where a crypto object forces it. From API 28 onwards the system BiometricPrompt is used and the theme does not matter.

    If you do need it:

    android/app/src/main/AndroidManifest.xml:

    <activity
        android:name=".MainActivity"
        android:launchMode="singleTop"
        android:theme="@style/LaunchTheme">
        [...]
        <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
    </activity>
    

    android/app/src/main/res/values/styles.xml:

    <resources>
      <style name="LaunchTheme" parent="Theme.AppCompat.NoActionBar">
        ...
      </style>
      <style name="NormalTheme" parent="Theme.AppCompat.NoActionBar">
        ...
      </style>
    </resources>
    
Logging

The plugin writes to android.util.Log under the tag BiometricStorage. A debug build logs everything; a release build logs nothing below INFO until you ask for it:

adb shell setprop log.tag.BiometricStorage VERBOSE

That suits reading logs off a device. If your app collects its own — a file appender, a crash reporter, slf4j, Timber — install a sink instead, from Application.onCreate or your FlutterActivity, before the first call into the plugin:

import android.util.Log
import design.codeux.biometric_storage.BiometricStorageLogging
import org.slf4j.LoggerFactory

BiometricStorageLogging.sink =
    BiometricStorageLogging.Sink { priority, tag, message, throwable ->
        val log = LoggerFactory.getLogger(tag)
        when (priority) {
            Log.VERBOSE -> log.trace(message, throwable)
            Log.DEBUG -> log.debug(message, throwable)
            Log.INFO -> log.info(message, throwable)
            Log.WARN -> log.warn(message, throwable)
            else -> log.error(message, throwable)
        }
    }

Installing a sink turns every level on, since it says something wants the records. To decide the level yourself — including keeping verbose logging in a release build without touching a device property — set it explicitly:

BiometricStorageLogging.level = Log.VERBOSE

throwable is passed separately rather than flattened into message, so you can hand the real exception to whatever you report to. The sink is called on whichever thread produced the record, so it must be safe to call from the main thread and from a background executor.

Resources
  • https://developer.android.com/topic/security/data
  • https://developer.android.com/topic/security/best-practices
iOS

https://developer.apple.com/documentation/localauthentication/logging_a_user_into_your_app_with_face_id_or_touch_id

  • include the NSFaceIDUsageDescription key in your app’s Info.plist file
  • Deployment target >= iOS 13 (below whatever Flutter itself requires, so in practice this never binds).

Known Issue: since iOS 15 the simulator seem to no longer support local authentication: https://developer.apple.com/forums/thread/685773

IosPromptInfo.saveTitle / accessTitle are invisible on Face ID devices. Face ID authenticates against a HUD that shows its glyph and the words "Face ID" and nothing else, and the "not recognized" alert after a failure offers only retry and cancel. The strings do reach the system — they are set as LAContext.localizedReason — but iOS does not draw them. Touch ID devices and macOS do show them, so they are still worth setting.

Mac OS
  • include the NSFaceIDUsageDescription key in your app’s Info.plist file
  • enable keychain sharing and signing. (not sure why this is required. but without it You will probably see an error like:

    SecurityError, Error while writing data: -34018: A required entitlement isn't present.

  • Deployment target >= macOS 10.15.
Swift Package Manager (iOS and Mac OS)

The iOS and macOS implementations ship both a Package.swift and a podspec, so they work with either dependency manager. Adding this plugin to an app that has migrated to Swift Package Manager does not bring CocoaPods back — no Podfile is generated.

Usage

You basically only need 4 methods.

  1. Check whether biometric authentication is supported by the device
  final response = await BiometricStorage().canAuthenticate()
  if (response != CanAuthenticateResponse.success) {
    // panic..
  }
  1. Create the access object
  final storageFile = await BiometricStorage().getStorage('mystorage');
  1. Read data
  final data = await storageFile.read();
  1. Write data
  final myNewData = 'Hello World';
  await storageFile.write(myNewData);

Storing without a biometric prompt — for a value a background task has to be able to refresh, for example — is authenticationRequired: false. The value is still encrypted at rest; it is simply not gated behind an authentication.

  final storageFile = await BiometricStorage().getStorage(
    'mystorage',
    options: StorageFileInitOptions(authenticationRequired: false),
  );

See also the API documentation: https://pub.dev/documentation/biometric_storage/latest/biometric_storage/BiometricStorageFile-class.html#instance-methods

카테고리

의존성

의존성 목록 4 개

  • ffi>=1.0.0 <3.0.0
  • logging>=1.0.0 <2.0.0
  • plugin_platform_interface^2.0.0
  • win32>=2.0.0 <6.0.0

소스 저장소

이 패키지를 사용하는 프로젝트