#authentication #password #fingerprint #robius #macos-ios #biometric

robius-authentication

Rust abstractions for multi-platform native authentication: biometrics, fingerprint, password, TouchID, FaceID, Windows Hello, etc

2 releases

0.1.1 Nov 1, 2024
0.1.0 Jun 12, 2024

#236 in Operating systems

Download history 7/week @ 2024-09-19 8/week @ 2024-09-26 8/week @ 2024-10-03 133/week @ 2024-10-31 4/week @ 2024-11-07

137 downloads per month

MIT license

320KB
1K SLoC

robius-authentication

Latest Version Docs Project Robius Matrix Chat

Rust abstractions for multi-platform native authentication.

This crate supports:

  • Apple: TouchID, FaceID, and regular username/password on both macOS and iOS.
  • Android: See below for additional steps.
    • Requires the USE_BIOMETRIC permission in your app's manifest.
  • Windows: Windows Hello (face recognition, fingerprint, PIN), plus winrt-based fallback for username/password.
  • Linux: polkit-based authentication using the desktop environment's prompt.
    • Note: Linux support is currently incomplete.

Usage on Android

For authentication to work, the following must be added to your app's AndroidManifest.xml:

<uses-permission android:name="android.permission.USE_BIOMETRIC" />

Example

use robius_authentication::{
    AndroidText, BiometricStrength, Context, Policy, PolicyBuilder, Text, WindowsText,
};

let policy: Policy = PolicyBuilder::new()
    .biometrics(Some(BiometricStrength::Strong))
    .password(true)
    .watch(true)
    .build()
    .unwrap();

let text = Text {
    android: AndroidText {
        title: "Title",
        subtitle: None,
        description: None,
    },
    apple: "authenticate",
    windows: WindowsText::new("Title", "Description"),
};

let auth_result = Context::new(()).blocking_authenticate(text, &policy);
...

For more details about the prompt text, see the Text struct, which allows you to customize the prompt for each platform.

Dependencies

~0–42MB
~641K SLoC