AuthPlugin

Trait AuthPlugin 

Source
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<(), PluginError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: '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>, PluginError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             Self: 'async_trait;
    fn validate_config(
        &self,
        config: &AuthPluginConfig,
    ) -> Result<(), PluginError>;
    fn supported_schemes(&self) -> Vec<String>;
    fn cleanup<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: '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§

Source

fn capabilities(&self) -> PluginCapabilities

Get plugin capabilities (permissions and limits)

Source

fn initialize<'life0, 'life1, 'async_trait>( &'life0 self, config: &'life1 AuthPluginConfig, ) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Initialize the plugin with configuration

Source

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>, PluginError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: '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 context
  • request - HTTP request information
  • config - Plugin configuration
§Returns

Authentication result indicating success/failure and user claims

Source

fn validate_config(&self, config: &AuthPluginConfig) -> Result<(), PluginError>

Validate plugin configuration

Source

fn supported_schemes(&self) -> Vec<String>

Get supported authentication schemes

Source

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

Cleanup plugin resources

Implementors§