Expand description
OS keychain integration with encrypted-file fallback.
§Architecture
KeychainBackend is a trait with three operations: set, get,
delete. Three concrete implementations live here:
KeyringBackend— wraps thekeyringcrate; active on macOS (Keychain), Windows (Credential Manager), and Linux (Secret Service).FileBackend— AES-256-GCM encryptedsecrets.encsidecar; used whenKeyringBackendinit fails (headless Linux, CI, locked DBus). Passphrase is supplied by the caller; prompting the user is deferred to the Credential Manager UI in task 18.StubBackend— in-memoryHashMapfor unit tests; gated behind thetest-keyring-stubcargo feature.
§OCP contract
Adding a new backend (e.g. OnePasswordBackend) requires only:
- A new struct implementing
KeychainBackend. - Optionally, extending
select_backendto return it. No existing code changes.
§Security contract
Secret carries #[serde(skip_serializing)] on every field so it
can never be emitted across Tauri IPC by accident. Fields are zeroed in
memory on drop via [zeroize::ZeroizeOnDrop].
Internal storage (keyring JSON blob, FileBackend map) uses StoredSecret,
a private mirror that CAN serialize all fields. The two structs are
intentionally separate to enforce the IPC-safe contract on Secret.
Structs§
- File
Backend 🔒 - Passphrase-encrypted file-based fallback for environments where the OS keychain is unavailable.
- File
Backend With Passphrase - Public file-based keychain backend.
- Keyring
Backend - Wraps the [
keyring] crate to store one entry per profile. - Secret
- AWS / provider credentials stored by a profile.
- Stored
Secret 🔒 - Private mirror of
Secretused for serialization inside storage backends. All fields are serialized normally. Never exposed over IPC.
Traits§
- Keychain
Backend - Backend-agnostic interface for persisting and retrieving credential secrets keyed by profile ID.
Functions§
- decrypt_
file 🔒 - Decrypt a
secrets.encfile and return the stored map. - derive_
key 🔒 - Derive a 32-byte AES-256-GCM key from
passphraseusing Argon2id. - select_
backend - Select the best available keychain backend at runtime.