localauthentication-rs
Safe Rust bindings for Apple's LocalAuthentication framework on macOS.
Status: v0.2.1 expands coverage across
LAContext,LAPolicy,LAError,LACredential,LAAuthenticationRequirement,LARight,LARightStore,LAPersistedRight,LAPublicKey,LAPrivateKey,LASecret, and the macOS 15LAEnvironmentobserver/state surface.
Platform notes
- The Rust crate is macOS-focused and links the system
LocalAuthentication.framework. - The Swift bridge now targets macOS 13+.
LAContext::domain_state()plus theLAEnvironment::{current_user, state, add_observer}surface are macOS 15+ APIs.- Persisted-right and key APIs can require signing or entitlements; the examples and tests treat
OSStatus -34018as an expected environment limitation. LAPrivateKey::exchange_keys_with_public_keyusesSecKeyExchangeParametersfor the requested derived-key length and optional shared-info KDF context.
Quick start
use *;
Highlights
LAContextlifecycle, policy preflight/evaluation, credential injection, domain-state snapshots, and raw access-control evaluationLAPolicy,LAError,LA_ERROR_DOMAIN,BiometryType, andLACompanionTypeLAAuthenticationRequirementandLABiometryFallbackRequirementbuilders for rightsLARightandLARightStorefor in-memory and persisted authorization flowsLAPersistedRight,LASecret,LAPrivateKey,LAPublicKey,SecKeyAlgorithm, andSecKeyExchangeParametershelpers for persisted secrets and asymmetric-key operationsLAEnvironment,LAEnvironmentObserver,LAEnvironmentState, and the environment mechanism subclasses for macOS 15 environment snapshots and change notifications- Backward-compatible aliases for the v0.1.x surface (
Policy,LocalAuthenticationError,context, anderror)
Examples
The crate ships numbered examples for every logical area:
01_smoke—LAContext, policies, credentials, and domain state02_policy_catalog— policy availability across biometric and companion modes03_error_codes—LAErrorand domain/code mapping04_credentials—LACredentialhelpers05_authentication_requirements— requirement builders andLARightconstruction06_rights— right state/tag/preflight/deauthorize flow07_right_store— sharedLARightStorepersistence entry points08_persisted_right—LAPersistedRight,LASecret, andLAPrivateKey09_public_key—LAPublicKeyexport plusLAPrivateKeyverify/encrypt/key-exchange capability checks10_environment—LAEnvironment, observer registration, and mechanism snapshots
Run the full verification matrix with:
for; do ; done
For the header-by-header audit, see COVERAGE.md.
License
Licensed under either of Apache-2.0 or MIT at your option.