Repository navigation
Description
Describe the problem
Currently, the authenticate method in the Biometric plugin only returns a boolean-like success or failure (via Result<()>). While this confirms that the user is the device owner, it doesn't provide a way to securely store or retrieve sensitive information (like an app's master key or login token) bound to the biometric factor.
In a high-security scenario, we need to ensure that certain data can only be decrypted or accessed if the biometric authentication was successful, leveraging hardware-backed security (Android Keystore / iOS Keychain with AccessControl). Simply trusting a "Success" callback from the OS is susceptible to hooks or bypasses on compromised devices.
Describe the solution you'd like
I would like the authenticate method to support cryptographic operations and return a "secret" or "token" upon successful authentication.
Proposed Changes:
- **Extended
AuthOptions**: Add a way to specify a key name or a payload to be processed. - Cryptographic Integration:
- Android: Support
BiometricPrompt.CryptoObject. The plugin should allow users to initialize aCipherorSignaturebacked by the Android Keystore that requires user authentication. - iOS: Support
SecAccessControlwithkSecAccessControlBiometryAnyorkSecAccessControlBiometryCurrentSet.
- Modified Return Type: Change
authenticateto return a value (e.g., a Base64 encoded string or aVec<u8>).
Updated Rust Interface Idea:
// Proposed model change
pub struct AuthResponse {
pub signature: Option<String>,
pub decrypted_data: Option<String>,
}
impl<R: Runtime> Biometric<R> {
pub fn authenticate(&self, reason: String, options: AuthOptions) -> crate::Result<AuthResponse> {
// ...
}
}Alternatives considered
Developers can currently try to write custom Kotlin/Swift code via Tauri's command system, but since the Biometric plugin already handles the complex UI and permission lifecycle of the Biometric Prompt, it makes more sense to integrate the "Secure Storage/Cryptographic" part directly into this official plugin.
Currently, the plugin only provides 'authentication' but not 'secure storage'. Without this feature, the plugin is just a UI wrapper for the system prompt, and doesn't actually help in creating a zero-trust security model.
Additional context
- On Android, this would involve using
KeyGenParameterSpec.Builder.setUserAuthenticationRequired(true). - On iOS, this would involve retrieving an item from the Keychain using
LAContextfor evaluation. - This is a standard feature in many other cross-platform biometric libraries (like
react-native-keychainor Flutter'slocal_authwith extra secure storage plugins).
Activity
surkaa commentedon Dec 18, 2025
Duplicate with PR #2454