pub struct Keyring {
pub ephemeral: bool,
/* private fields */
}Expand description
Holds decrypted API keys in memory. Keys are mlock’d and zeroized on drop.
Fields§
§ephemeral: boolWhether keys were loaded from a sealed source (one-shot key). When true, credential files should be wiped after each use.
Implementations§
Source§impl Keyring
impl Keyring
Sourcepub fn load(keyring_path: &Path) -> Result<Self, KeyringError>
pub fn load(keyring_path: &Path) -> Result<Self, KeyringError>
Load the keyring: read sealed key file, decrypt keyring.enc, mlock memory.
The session key file is deleted immediately after reading.
Sourcepub fn load_with_key(
keyring_path: &Path,
session_key: &[u8; 32],
) -> Result<Self, KeyringError>
pub fn load_with_key( keyring_path: &Path, session_key: &[u8; 32], ) -> Result<Self, KeyringError>
Load from an already-known session key (for testing or orchestrator use).
Sourcepub fn load_credentials(path: &Path) -> Result<Self, KeyringError>
pub fn load_credentials(path: &Path) -> Result<Self, KeyringError>
Load from a plaintext credentials file (JSON object: {“key_name”: “value”, …}).
Used in local mode where ~/.ati/credentials stores keys as plaintext JSON
with 0600 permissions (same approach as AWS CLI, gh, Docker, Stripe).
Sourcepub fn load_local(
keyring_path: &Path,
ati_dir: &Path,
) -> Result<Self, KeyringError>
pub fn load_local( keyring_path: &Path, ati_dir: &Path, ) -> Result<Self, KeyringError>
Load keyring.enc using a persistent key stored alongside the ATI directory.
Looks for <ati_dir>/.keyring-key (base64-encoded 32-byte key).
Unlike the sealed key in /run/ati/.key, this key is NOT deleted after reading —
it’s for proxy servers with persistent storage.
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Create a keyring from environment variables with ATI_KEY_ prefix.
Scans all env vars matching ATI_KEY_*, strips the prefix, lowercases the name.
Example: ATI_KEY_FINNHUB_API_KEY=abc123 → key name finnhub_api_key.