Skip to main content

KeyStore

Trait KeyStore 

Source
pub trait KeyStore: Send + Sync {
    // Required methods
    fn create_key<'life0, 'life1, 'async_trait>(
        &'life0 self,
        record: &'life1 KeyRecord,
    ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn list_keys<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<KeyRecord>, StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn revoke_key<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<DateTime<Utc>>, StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn validate_key<'life0, 'life1, 'async_trait>(
        &'life0 self,
        raw_key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<KeyRecord>, StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Trait for persistent API key storage.

Required Methods§

Source

fn create_key<'life0, 'life1, 'async_trait>( &'life0 self, record: &'life1 KeyRecord, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Stores a new key record. The key_hash field must already be set.

Source

fn list_keys<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<KeyRecord>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Lists all keys (including revoked, for admin view).

Source

fn revoke_key<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<DateTime<Utc>>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Revokes a key by its ID. Returns the revocation timestamp.

Source

fn validate_key<'life0, 'life1, 'async_trait>( &'life0 self, raw_key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<KeyRecord>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Validates a plaintext key and returns its record if active.

Implementors§