EncryptedFilesystemStorage

Struct EncryptedFilesystemStorage 

Source
pub struct EncryptedFilesystemStorage { /* private fields */ }
Expand description

Encrypted filesystem storage for secure credential storage

This implementation encrypts data at rest using the age encryption library. It provides a secure alternative to keyring when:

  • Keyring is unavailable (headless environments, CI/CD)
  • Platform keyring integration is not possible
  • Remote/containerized environments

§Encryption Key Management

The encryption key is obtained in the following priority order:

  1. Environment Variable: RUNBEAM_ENCRYPTION_KEY (base64-encoded)
  2. Generated Key: Automatically generated and stored at ~/.runbeam/encryption.key

Generated keys are created with restrictive file permissions (0600 on Unix) to prevent unauthorized access.

§Security Considerations

  • DO NOT commit encryption keys to version control
  • In production, use RUNBEAM_ENCRYPTION_KEY environment variable
  • Protect the ~/.runbeam/encryption.key file with appropriate file system permissions
  • Consider key rotation policies for long-lived deployments
  • In containerized environments, use secrets management (e.g., Docker secrets, k8s secrets)

Implementations§

Source§

impl EncryptedFilesystemStorage

Source

pub async fn new_with_instance(instance_id: &str) -> Result<Self, StorageError>

Create a new encrypted filesystem storage with an instance-specific key

Uses ~/.runbeam/<instance_id> as the base path for storage and keys. This allows multiple instances to have isolated storage.

§Arguments
  • instance_id - Unique identifier for this instance (e.g., “harmony”, “runbeam-cli”, “test-123”)
§Returns

Returns a configured EncryptedFilesystemStorage or an error if:

  • The base path cannot be created
  • Encryption key cannot be loaded or generated
  • Key file permissions cannot be set properly
Source

pub async fn new_with_instance_and_key( instance_id: &str, encryption_key: &str, ) -> Result<Self, StorageError>

Create a new encrypted filesystem storage with an explicit encryption key

Uses ~/.runbeam/<instance_id> as the base path for storage. The provided encryption key will be used instead of environment variables or auto-generation.

§Arguments
  • instance_id - Unique identifier for this instance (e.g., “harmony”, “runbeam-cli”, “test-123”)
  • encryption_key - Base64-encoded age X25519 encryption key
§Returns

Returns a configured EncryptedFilesystemStorage or an error if:

  • The base path cannot be created
  • The encryption key is invalid
Source

pub async fn new(base_path: impl AsRef<Path>) -> Result<Self, StorageError>

Create a new encrypted filesystem storage

§Arguments
  • base_path - Base directory for encrypted file storage
§Returns

Returns a configured EncryptedFilesystemStorage or an error if:

  • The base path cannot be created
  • Encryption key cannot be loaded or generated
  • Key file permissions cannot be set properly

Trait Implementations§

Source§

impl StorageBackend for EncryptedFilesystemStorage

Source§

fn write_file_str( &self, path: &str, data: &[u8], ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + '_>>

Write data to storage at the specified path
Source§

fn read_file_str( &self, path: &str, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, StorageError>> + Send + '_>>

Read data from storage at the specified path
Source§

fn exists_str(&self, path: &str) -> bool

Check if a file exists at the specified path
Source§

fn remove_str( &self, path: &str, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + '_>>

Remove a file at the specified path

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,