Introducing a new way to review your PRs.

Read the announcement

fwdai / rowel

🔑 Local-first Secrets Manager

View on GitHub

23 documents · Updated Oct 9, 2026

docs / biometrics-and-secure-storage

Biometrics and secure storage

Biometric unlock lets a user reopen the app without typing the master password. The native layer places the app key behind an operating-system biometric gate, while the frontend uses a small status contract to offer enrollment and unlock only when the current workspace can be opened. See Security and access for the wider security model and Authentication, locking, and access lifecycle for password and lock transitions.

Enrollment model

Enrollment is an opt-in action taken while the app is unlocked. The system stores opaque key material in the native secure store and writes a non-secret marker that records which protection mode was selected. The marker does not contain the key.

Enrollment state

The stored material is the app key, which is the primary workspace key used to open the other workspace keys on this device. The enrollment mode is chosen once when the key is stored. Later unlocks use that recorded mode and do not silently switch to a weaker or different gate.

The enrollment state has three useful properties:

  • Enabling requires a live app key. A workspace opened with its own password cannot enroll until the primary key is also known.
  • Disabling removes the native key and the marker.
  • Re-enrollment removes old mode entries before writing the new one, so stale keys do not remain usable.
  • The stored key is tied to the selected platform gate. The app does not treat a key in an ungated store as an equivalent enrollment.

References: src-tauri/…/secure_store.rs• L31-37 src-tauri/…/secure_store.rs• L55-112 src-tauri/…/storage.rs• L32-36 src-tauri/…/storage.rs• L582-614

Authentication flow

Biometric authentication is a native proof that releases the stored app key. The backend then opens the active workspace and creates the same unlocked session used by password authentication. The master key stays in native memory during this flow; the frontend receives only the normal unlock result.

The main path is:

flowchart LR
    A[Frontend unlock action] --> B[Native biometric gate]
    B -->|approved| C[Read app key]
    C --> D[Open primary or wrapped workspace key]
    D --> E[Create unlocked session]
    B -->|cancelled or failed| F[Keep lock screen]

Cancellation is different from a missing enrollment. A cancelled prompt leaves the enrollment in place, while a proven missing key clears the marker so the frontend stops offering a gate that cannot work.

References: src-tauri/…/auth.rs• L224-306 src-tauri/…/biometrics.rs• L148-185 src-tauri/…/appkey.rs• L160-181

Workspace access

One biometric enrollment serves the device rather than one workspace. The primary workspace uses the stored app key directly. Each other workspace is offered for biometric unlock only after its key has been sealed under that app key on the device.

This boundary prevents a biometric unlock from claiming to open a workspace whose key is not available. It also keeps the device-local app-key relationship separate from synced vault data, which still uses the workspace's own password-derived protection.

References: src-tauri/…/appkey.rs• L1-21 src-tauri/…/appkey.rs• L115-135 src-tauri/…/auth.rs• L229-291 src-tauri/…/app.rs• L105-125

Platform protection boundaries

The native layer uses the strongest gate that the platform and the signed app can support. The protection boundary differs by platform, so the frontend must describe the mode that enrollment actually selected rather than assume that every biometric prompt protects a stored credential in the same way.

Apple protection

Apple builds prefer a data-protection Keychain item that requires the current biometric set. The operating system enforces the check when the item is read, binds the item to the device, requires a device passcode, and invalidates it when the enrolled biometric set changes. On macOS this path needs the correct keychain entitlement; iOS uses the protected keychain path without that macOS switch.

On iOS the enrolled item is placed in the app group shared with the related extension. Older items can be adopted into that shared group during a successful read, so the extension and the app use the same device-bound key without changing the biometric gate.

An unentitled macOS build can use a weaker but explicit fallback. It performs a native biometric check first and then reads an ordinary login-Keychain item. This fallback is selected only when the protected store reports the specific entitlement gap, not for arbitrary keychain failures. A signed macOS build must also pair the keychain entitlement with a valid provisioning profile; an invalid entitlement pairing can stop the app before its code runs rather than select this fallback.

References: src-tauri/…/secure_store.rs• L7-20 src-tauri/…/secure_store.rs• L244-290 src-tauri/…/secure_store.rs• L357-409 src-tauri/Entitlements.plist• L3-35

Windows Hello protection

Windows uses a Hello key credential to wrap the app key before placing the resulting blob in Credential Manager. Reading the blob requires a new Hello-backed signature, so a process that can read Credential Manager as the same user still cannot open the stored blob without passing Windows Hello.

The credential and the wrapped blob are treated as one enrollment. Enrollment confirms that the device can reproduce the required proof before it stores the blob. If either part is missing or the Hello key no longer reproduces the enrollment proof, the user must enroll again rather than receive an unprotected copy. Older enrollments that stored an ungated copy are removed instead of being opened.

References: src-tauri/…/secure_store.rs• L106-161 src-tauri/…/secure_store.rs• L440-591 src-tauri/…/biometrics.rs• L79-115

Unsupported platform behavior

Platforms without a supported biometric-gated secure store do not save the vault key for biometric use. The native probe reports biometric capability as unavailable, and the frontend hides or disables enrollment instead of storing a key without a gate.

References: src-tauri/…/secure_store.rs• L81-98 src-tauri/…/secure_store.rs• L647-665 src-tauri/…/biometrics.rs• L118-131

Frontend contract

The frontend does not inspect the native secure store. It reads a locked-safe status snapshot and calls three native commands: enable, disable, and unlock. The snapshot separates device capability from current enrollment so setup can offer enrollment before an enrollment exists.

Status probe

The app_status response exposes four biometric facts:

FieldMeaning
availableA key is enrolled and can open the active workspace now.
canEnrollThe platform has a usable biometric gate and the app key is known in the current session.
typeThe device gate name: face, touch, or none.
modeThe protection mode recorded for the enrollment, or null when none exists.

The frontend keeps this snapshot in the app store. It refreshes the snapshot after enrollment, disablement, unlock, and lock so the lock screen and Settings do not infer native state from an earlier action.

References: src-tauri/…/app.rs• L42-129 src/…/app.ts• L51-100 src/…/types.ts• L223-233 src/…/app.ts• L140-196

Enrollment controls

Setup asks about biometrics after a successful first unlock and offers a skip action. Settings exposes the same choice later. Both paths call the same native command and redraw from a fresh status probe, which lets the UI show the protection mode that the platform actually selected.

The controls are unavailable when the device cannot gate the secure store or when the current session does not hold the app key. A failed enrollment stays recoverable because the user can continue without biometric unlock or try again from Settings.

References: src/…/index.tsx• L125-142 src/…/index.tsx• L19-64 src/…/BiometricRow.tsx• L12-74 src/…/auth.ts• L17-26

Unlock controls

When available is true, the lock screen gives the biometric action priority and keeps master-password entry one action away. The label and icon use the reported device type, so the UI can say Face ID or Touch ID without guessing from the build target.

The biometric action calls unlock_biometric. It reports success through the normal unlock result and reports cancellation or failure as a lock-screen error. The end-to-end suite does not drive this prompt because the OS owns it and the secure store is machine-bound; native unit coverage exercises the platform seam instead.

References: src/…/LockScreen.tsx• L19-85 src/…/BiometricTile.tsx• L6-33 src/…/biometry.ts• L4-18 src/…/auth.ts• L17-18 tests/…/COVERAGE.md• L70-78

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the persisted enrollment marker and the native gate mode aligned. A new marker value needs matching read behavior and frontend status handling.
  • If the app-key or workspace wrapping rules change, recheck available so the lock screen does not offer biometric unlock for a workspace that lacks a wrapped key.
  • If the platform store changes, preserve the distinction between a user cancellation, a missing enrollment, and a store or entitlement failure. Only a confirmed missing enrollment should clear the marker.
  • If the master-key format or primary password flow changes, refresh the stored app key when biometric enrollment is active.
  • If the Apple keychain access group changes, check the app group and extension access path together. On macOS, check the entitlement against the provisioning profile.
  • If the frontend status shape changes, update setup, Settings, the lock screen, and the TypeScript biometric unions together.

Important failure modes

TriggerConsequenceGuard
The enrolled biometric set changes on an Apple deviceThe protected Keychain item becomes unavailable and biometric unlock cannot release the app key.Treat the missing item as a lost enrollment and require re-enrollment.
A macOS build lacks the protected-keychain entitlementOS-enforced enrollment cannot be stored in that build.Fall back only to the explicit prompt-then-read mode for the entitlement error.
A macOS entitlement is not allowed by the signed provisioning profileThe operating system can terminate the app before its code starts.Keep the keychain group and profile grants aligned and validate the signed release bundle.
The user dismisses or cancels the biometric promptThe vault stays locked, but a valid enrollment remains.Return a cancellation result and keep the marker.
A Windows Hello credential or its stored blob is missingThe wrapped app key cannot be reconstructed.Remove or replace the enrollment instead of reading an unprotected credential copy.
The active workspace has no key sealed under the app keyBiometric unlock could open the primary but not that workspace.Set available false for that workspace and require its password first.
A platform has biometric hardware but no supported secure-store gateA prompt may exist, but saving the vault key would not create a safe unlock path.Require both biometric availability and secure-store support before enrollment.

Key files

FileWhy to read it
src-tauri/…/secure_store.rsDefines the platform gate modes and the native secure-store boundary.
src-tauri/Entitlements.plistDefines the macOS signing boundary needed for the protected Keychain path and the shared app group.
src-tauri/…/biometrics.rsDefines the OS biometric probe and authentication result boundary.
src-tauri/…/auth.rsConnects enrollment and biometric unlock to the live session.
src-tauri/…/app.rsBuilds the locked-safe status snapshot consumed by the frontend.
src-tauri/…/appkey.rsExplains how one device-level app key reaches multiple workspaces.
src-tauri/…/storage.rsDefines the non-secret enrollment marker and its lifecycle.
src/…/auth.tsExposes the frontend calls for unlock, enrollment, and disablement.
src/…/app.tsDefines the frontend status contract for biometric capability and enrollment.
src/…/LockScreen.tsxShows how biometric unlock is offered beside master-password entry.
src/…/BiometricRow.tsxShows how users enable or disable the feature after setup.