Giter VIP home page Giter VIP logo

eaceto / flutter_local_authentication Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 9.0 411 KB

A flutter plugin that allows access to Local Authentication / Biometrics on iOS, macOS, Linux and Android (Windows Hello is a work in progress).

Home Page: https://eaceto.dev

License: MIT License

Kotlin 9.00% Ruby 3.91% Swift 13.50% Objective-C 0.03% Dart 21.99% CMake 22.22% C++ 27.02% C 2.33%
android biometric biometric-authentication biometric-identification dart fingerprint flutter ios local-authentication macos

flutter_local_authentication's Introduction

Local Authentication

A flutter plugin that allows access to Local Authentication / Biometrics on iOS, macOS, Linux and Android (Windows Hello is a work in progress).

  1. Features
  2. Changelog
  3. Usage 3.1. Initialization 3.2. Localization 3.3. Querying support and performing Local Authentication
  4. Considerations 4.1. canAuthenticate 4.2. Supported Platforms
  5. Next Steps
  6. Contribution
  7. License
  8. Code of Conduct

Features

  • Detects if biometric authentication can be done in the current platform (canAuthenticate).

  • Triggers platform's native authentication for the current user (authenticate).

  • Read/Write macOS/iOS touchIDAuthenticationAllowableReuseDuration value

  • Localized messages for iOS, macOS and Android

Usage

Initialization

Initialize an instance of the plugin, which requires no input parameters.

  final _flutterLocalAuthenticationPlugin = FlutterLocalAuthentication();

Localization

At any time a localization model can be applied. The latests applied is used by the plugin when the local authentication is performed.

    final localization = LocalizationModel(
        promptDialogTitle: "title for dialog",
        promptDialogReason: "reason for prompting biometric",
        cancelButtonTitle: "cancel"
    );
    _flutterLocalAuthenticationPlugin.setLocalizationModel(localization);

Querying support and performing Local Authentication

Two functions are available for the core feature of this library:

  • canAuthenticate
  • authenticate

Depending on each platform the behaviour of canAuthenticate can differ.

    bool canAuthenticate;
    try {
      // Query suppor for Local Authentication
      canAuthenticate = await _flutterLocalAuthenticationPlugin.canAuthenticate();

      // Setup TouchID Allowable Reuse duration
      // It works only in iOS and macOS, but it's safe to call it even on other platforms.
      await _flutterLocalAuthenticationPlugin.setTouchIDAuthenticationAllowableReuseDuration(30);
    } on Exception catch (error) {
      debugPrint("Exception checking support. $error");
      canAuthenticate = false;
    }

    if (canAuthenticate) {
      // Perform Local Authentication

      _flutterLocalAuthenticationPlugin.authenticate().then((authenticated) {
        String result = 'Authenticated: $authenticated';
        // handle result
      }).catchError((error) {
        String result = 'Exception: $error';
        // handle error
      });
    }

Considerations

canAuthenticate

The function canAuthenticate will return true in the following scenarios.

  • Android: true if BiometricManager returns that it can authenticate with one of the following allowed authenticators:

    • BiometricManager.Authenticators.BIOMETRIC_STRONG
    • BiometricManager.Authenticators.BIOMETRIC_WEAK
    • BiometricManager.Authenticators.DEVICE_CREDENTIAL
  • iOS: true if LAContext.supportsLocalAuthentication returns true for device policy:

    • deviceOwnerAuthenticationWithBiometrics
  • macOS: true if LAContext.supportsLocalAuthentication returns true for device policy:

    • deviceOwnerAuthentication
  • linux: true if fprintd-verify is installed and user can execute it.

Supported platforms

  • iOS 12 or newer
  • macOS 10.12.2 or newer
  • Linux (requires libfprint)
  • Android 6.0 or newer

Next Steps

  • Add support to Windows Hello

flutter_local_authentication's People

Contributors

eaceto avatar prateekmedia avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

flutter_local_authentication's Issues

Android 10 supportsAuthentication is false

Tested device: Xiaomi Mi A2
enrolled with finger + pin
getting always false, permission with USE_BIOMETRIC added in all three manifests.
in app info i see, that it uses biometric

authenticate() always returns true after first successful biometric verification on macOS

Steps to reproduce:

  • Initialize FlutterLocalAuthentication
  • Call authenticate method
  • Biometric popup will be shown
  • Provide the correct biometric
  • authenticate method will return true [This is expected]
  • Now call authenticate again
  • This will immediately return true [This is not expected]

What I tried:

  • Setting setTouchIDAuthenticationAllowableReuseDuration to "0" or any other value has no effect on this behaviour

Status of Windows support?

I am evaluating this plugin compared to local_auth and currently I prefer this one as it's Swift (not Obj-C) and more importantly has MacOS support.

However the Windows support still seems like it's incomplete are there still plans to add windows support - is it feasible to port the Windows implementation in the local_auth plugin?

Thanks for the plugin!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.