pub trait AuthPlugin: Send + Sync {
// Required methods
fn capabilities(&self) -> PluginCapabilities;
fn initialize<'life0, 'life1, 'async_trait>(
&'life0 self,
config: &'life1 AuthPluginConfig,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn authenticate<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
context: &'life1 PluginContext,
request: &'life2 AuthRequest,
config: &'life3 AuthPluginConfig,
) -> Pin<Box<dyn Future<Output = Result<PluginResult<AuthResponse>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
fn validate_config(&self, config: &AuthPluginConfig) -> Result<()>;
fn supported_schemes(&self) -> Vec<String>;
fn cleanup<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}
Expand description
Authentication plugin trait
Implement this trait to create custom authentication methods for MockForge. Authentication plugins are called during the request processing pipeline to validate incoming requests.
Required Methods§
Sourcefn capabilities(&self) -> PluginCapabilities
fn capabilities(&self) -> PluginCapabilities
Get plugin capabilities (permissions and limits)
Sourcefn initialize<'life0, 'life1, 'async_trait>(
&'life0 self,
config: &'life1 AuthPluginConfig,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn initialize<'life0, 'life1, 'async_trait>(
&'life0 self,
config: &'life1 AuthPluginConfig,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Initialize the plugin with configuration
Sourcefn authenticate<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
context: &'life1 PluginContext,
request: &'life2 AuthRequest,
config: &'life3 AuthPluginConfig,
) -> Pin<Box<dyn Future<Output = Result<PluginResult<AuthResponse>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn authenticate<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
context: &'life1 PluginContext,
request: &'life2 AuthRequest,
config: &'life3 AuthPluginConfig,
) -> Pin<Box<dyn Future<Output = Result<PluginResult<AuthResponse>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Authenticate a request
This method is called for each incoming request that requires authentication. The plugin should examine the request headers, body, and other context to determine if the request is authenticated.
§Arguments
context
- Plugin execution contextrequest
- HTTP request informationconfig
- Plugin configuration
§Returns
Authentication result indicating success/failure and user claims
Sourcefn validate_config(&self, config: &AuthPluginConfig) -> Result<()>
fn validate_config(&self, config: &AuthPluginConfig) -> Result<()>
Validate plugin configuration
Sourcefn supported_schemes(&self) -> Vec<String>
fn supported_schemes(&self) -> Vec<String>
Get supported authentication schemes