pub trait ApiKeyStore: Send + Sync {
// Required methods
fn create<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 ApiKeyRecord,
) -> Pin<Box<dyn Future<Output = Result<(), ApiKeyError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn find_by_hash<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<ApiKeyRecord>, ApiKeyError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn find_and_verify_key<'life0, 'life1, 'async_trait>(
&'life0 self,
plaintext_key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<ApiKeyRecord>, ApiKeyError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn find_by_user<'life0, 'life1, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<ApiKeyRecord>, ApiKeyError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn record_usage<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<(), ApiKeyError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn revoke<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<(), ApiKeyError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn delete<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<(), ApiKeyError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn rotate<'life0, 'async_trait>(
&'life0 self,
old_key_id: Uuid,
expires_in_days: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<(ApiKeyRecord, String), ApiKeyError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
API key storage trait
Required Methods§
Sourcefn create<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 ApiKeyRecord,
) -> Pin<Box<dyn Future<Output = Result<(), ApiKeyError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn create<'life0, 'life1, 'async_trait>(
&'life0 self,
record: &'life1 ApiKeyRecord,
) -> Pin<Box<dyn Future<Output = Result<(), ApiKeyError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Store a new API key
Sourcefn find_by_hash<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<ApiKeyRecord>, ApiKeyError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn find_by_hash<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<ApiKeyRecord>, ApiKeyError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Find a key by its hash (for legacy SHA-256 compatibility)
Sourcefn find_and_verify_key<'life0, 'life1, 'async_trait>(
&'life0 self,
plaintext_key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<ApiKeyRecord>, ApiKeyError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn find_and_verify_key<'life0, 'life1, 'async_trait>(
&'life0 self,
plaintext_key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<ApiKeyRecord>, ApiKeyError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Find and verify a key using Argon2 Recommended approach: extract key ID from prefix for O(1) lookup
Sourcefn find_by_user<'life0, 'life1, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<ApiKeyRecord>, ApiKeyError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn find_by_user<'life0, 'life1, 'async_trait>(
&'life0 self,
user_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<ApiKeyRecord>, ApiKeyError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Find all keys for a user
Sourcefn record_usage<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<(), ApiKeyError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn record_usage<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<(), ApiKeyError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Update last_used_at timestamp
Sourcefn revoke<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<(), ApiKeyError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn revoke<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<(), ApiKeyError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Revoke a key
Sourcefn delete<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<(), ApiKeyError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn delete<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<(), ApiKeyError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Delete a key