Skip to content
This repository was archived by the owner on Jul 7, 2025. It is now read-only.

Rust abstractions for multi-platform native authentication (biometric, fingerprint, password, FaceID, TouchID etc)

Notifications You must be signed in to change notification settings

project-robius/robius-authentication

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Archived: this has moved to https://github.com/project-robius/robius

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.
    • Requires the NSFaceIDUsageDescription key in your app's Info.plist file.
  • Android: Biometric prompt and regular screen lock. 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 iOS

To use this crate on iOS, you must add the following to your app's Info.plist:

<key>NSFaceIDUsageDescription</key>
<string>Insert your usage description here</string>

Usage on Android

To use this crate on Android, you must add the following 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)
    .companion(true)
    .build()
    .unwrap();

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

let callback = |auth_result| {
    match auth_result {
        Ok(_)  => log::info!("Authentication success!"),
        Err(_) => log::error!(Authentication failed!"),
    }
};

Context::new(())
    .authenticate(text, &policy, callback)
    .expect("Authentication failed");

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

About

Rust abstractions for multi-platform native authentication (biometric, fingerprint, password, FaceID, TouchID etc)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •