pub trait ApiKeyAuth: Send + Sync {
// Required methods
async fn validate_api_key(
&self,
api_key: &str,
) -> AuthResult<TokenValidation>;
async fn create_api_key(
&self,
user_id: &str,
name: &str,
expires_in: Option<u64>,
) -> AuthResult<String>;
async fn revoke_api_key(&self, api_key: &str) -> AuthResult<()>;
async fn list_api_keys(&self, user_id: &str) -> AuthResult<Vec<ApiKeyInfo>>;
}Expand description
API Key 认证 trait
Required Methods§
Sourceasync fn validate_api_key(&self, api_key: &str) -> AuthResult<TokenValidation>
async fn validate_api_key(&self, api_key: &str) -> AuthResult<TokenValidation>
Sourceasync fn create_api_key(
&self,
user_id: &str,
name: &str,
expires_in: Option<u64>,
) -> AuthResult<String>
async fn create_api_key( &self, user_id: &str, name: &str, expires_in: Option<u64>, ) -> AuthResult<String>
Sourceasync fn revoke_api_key(&self, api_key: &str) -> AuthResult<()>
async fn revoke_api_key(&self, api_key: &str) -> AuthResult<()>
Sourceasync fn list_api_keys(&self, user_id: &str) -> AuthResult<Vec<ApiKeyInfo>>
async fn list_api_keys(&self, user_id: &str) -> AuthResult<Vec<ApiKeyInfo>>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.