localauthentication-rs
Safe Rust bindings for Apple's LocalAuthentication framework on macOS.
Status: v0.2.0 expands coverage across
LAContext,LAPolicy,LAError,LACredential,LAAuthenticationRequirement,LARight,LARightStore,LAPersistedRight,LAPublicKey,LAPrivateKey, andLASecret.
Platform notes
- The Rust crate is macOS-focused and links the system
LocalAuthentication.framework. - The Swift bridge now targets macOS 13+.
LAContext::domain_state()and companion-domain details 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.
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, andSecKeyAlgorithmhelpers for persisted secrets and asymmetric-key operations- 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, verify, and encrypt capability checks
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.