pub struct Manager<S> { /* private fields */ }Expand description
Manager for issuing, validating, and rotating API keys.
Implementations§
Source§impl<S: Store> Manager<S>
impl<S: Store> Manager<S>
Sourcepub async fn issue_key(
&self,
key_id: &str,
owner_id: &str,
name: &str,
prefix: &str,
scopes: &[String],
expires_at: Option<DateTime<Utc>>,
) -> Result<(GenerateResult, Key), AppError>
pub async fn issue_key( &self, key_id: &str, owner_id: &str, name: &str, prefix: &str, scopes: &[String], expires_at: Option<DateTime<Utc>>, ) -> Result<(GenerateResult, Key), AppError>
Issue and persist a new key.
Sourcepub async fn validate_key_with_scopes(
&self,
plain_key: &str,
required_scopes: &[String],
) -> Result<Key, AppError>
pub async fn validate_key_with_scopes( &self, plain_key: &str, required_scopes: &[String], ) -> Result<Key, AppError>
Validate a plaintext key.
Sourcepub async fn rotate_key(
&self,
old_key_id: &str,
config: RotationConfig,
) -> Result<RotationResult, AppError>
pub async fn rotate_key( &self, old_key_id: &str, config: RotationConfig, ) -> Result<RotationResult, AppError>
Rotate a key and issue a replacement.
Trait Implementations§
Source§impl<S: Store> KeyValidator for Manager<S>
impl<S: Store> KeyValidator for Manager<S>
Source§fn validate_key<'life0, 'life1, 'async_trait>(
&'life0 self,
plain_key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Key, AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn validate_key<'life0, 'life1, 'async_trait>(
&'life0 self,
plain_key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Key, AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Look up a key by its plaintext value, validate it, and return metadata.
Auto Trait Implementations§
impl<S> Freeze for Manager<S>where
S: Freeze,
impl<S> RefUnwindSafe for Manager<S>where
S: RefUnwindSafe,
impl<S> Send for Manager<S>where
S: Send,
impl<S> Sync for Manager<S>where
S: Sync,
impl<S> Unpin for Manager<S>where
S: Unpin,
impl<S> UnsafeUnpin for Manager<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for Manager<S>where
S: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more