Expand description
The OS credential store: macOS Keychain, Windows Credential Manager, and the Secret Service on other Unixes.
This is the only place in the workspace that talks to a platform credential
store. Callers work in terms of an account string and get plain
Result<_, String> back; which OS facility answers, and whether one exists
at all, is entirely this module’s problem.
§Platforms without a credential store
There are two separate ways this can be unavailable, and both are ordinary rather than exceptional:
- Not built in. The
keychainfeature is on by default but can be turned off - for a target thekeyringcrate does not support, or for a minimal build that should not link platform credential libraries at all. With it off,is_supportedisfalseand every operation returns a plain “not supported in this build” error. - Built in, but nothing to talk to. A headless Linux box with no Secret Service running, a locked keychain, a container, an SSH session with no session keyring. The code is present, the platform simply has no store.
Neither is treated as a crash or a panic, and neither is silently swallowed.
Leviath’s default credential backend is its own 0600 files precisely
because these situations are common; the keychain is opt-in, so an
unavailable one costs a clear error at startup and nothing else.
§Why the split into raw_* and interpret_*
The functions that touch the OS are deliberately branch-free delegation, and every decision about what a result means lives in a pure function beside them. That is what makes this module testable: no CI runner has an unlocked login keychain, and a test that reached a developer’s real one would raise an OS authorization prompt and hang. Tests install an in-memory store as the process default and drive this same code, unchanged, all the way down.
Functions§
- delete
- Remove
account, reporting whether anything was actually removed. - get
- The secret stored for
account, orNonewhen there is none. - is_
supported - Whether this build can talk to an OS credential store at all.
- probe
- Check that a usable credential store exists, without storing anything.
- set
- Store
secretunderaccount, replacing anything already there.