pub struct AuthPlugin {Show 19 fields
pub id: String,
pub version: Option<String>,
pub options: Option<Value>,
pub endpoints: Vec<AsyncAuthEndpoint>,
pub middlewares: Vec<PluginMiddleware>,
pub async_middlewares: Vec<PluginAsyncMiddleware>,
pub on_request: Option<Arc<dyn Fn(&AuthContext, Request<Vec<u8>>) -> Result<PluginRequestAction, RustAuthError> + Send + Sync>>,
pub on_response: Option<Arc<dyn Fn(&AuthContext, &Request<Vec<u8>>, Response<Vec<u8>>) -> Result<Response<Vec<u8>>, RustAuthError> + Send + Sync>>,
pub on_response_async: Option<Arc<dyn for<'a> Fn(&'a AuthContext, &'a Request<Vec<u8>>, &'a Response<Vec<u8>>) -> Pin<Box<dyn Future<Output = Result<(), RustAuthError>> + Send + 'a>> + Send + Sync>>,
pub init: Option<Arc<dyn Fn(&AuthContext) -> Result<PluginInitOutput, RustAuthError> + Send + Sync>>,
pub schema: Vec<PluginSchemaContribution>,
pub rate_limit: Vec<PluginRateLimitRule>,
pub hooks: PluginEndpointHooks,
pub error_codes: Vec<PluginErrorCode>,
pub database_hooks: Vec<PluginDatabaseHook>,
pub migrations: Vec<PluginMigration>,
pub social_providers: Vec<Arc<dyn SocialOAuthProvider>>,
pub password_validators: Vec<PluginPasswordValidator>,
pub state: Option<Arc<dyn Any + Send + Sync>>,
}Fields§
§id: String§version: Option<String>§options: Option<Value>§endpoints: Vec<AsyncAuthEndpoint>§middlewares: Vec<PluginMiddleware>§async_middlewares: Vec<PluginAsyncMiddleware>§on_request: Option<Arc<dyn Fn(&AuthContext, Request<Vec<u8>>) -> Result<PluginRequestAction, RustAuthError> + Send + Sync>>§on_response: Option<Arc<dyn Fn(&AuthContext, &Request<Vec<u8>>, Response<Vec<u8>>) -> Result<Response<Vec<u8>>, RustAuthError> + Send + Sync>>§on_response_async: Option<Arc<dyn for<'a> Fn(&'a AuthContext, &'a Request<Vec<u8>>, &'a Response<Vec<u8>>) -> Pin<Box<dyn Future<Output = Result<(), RustAuthError>> + Send + 'a>> + Send + Sync>>§init: Option<Arc<dyn Fn(&AuthContext) -> Result<PluginInitOutput, RustAuthError> + Send + Sync>>§schema: Vec<PluginSchemaContribution>§rate_limit: Vec<PluginRateLimitRule>§hooks: PluginEndpointHooks§error_codes: Vec<PluginErrorCode>§database_hooks: Vec<PluginDatabaseHook>§migrations: Vec<PluginMigration>§password_validators: Vec<PluginPasswordValidator>§state: Option<Arc<dyn Any + Send + Sync>>Implementations§
Source§impl AuthPlugin
impl AuthPlugin
pub fn new(id: impl Into<String>) -> AuthPlugin
pub fn with_version(self, version: impl Into<String>) -> AuthPlugin
pub fn with_options(self, options: Value) -> AuthPlugin
pub fn with_endpoint(self, endpoint: AsyncAuthEndpoint) -> AuthPlugin
pub fn with_init<F>(self, init: F) -> AuthPlugin
pub fn with_schema(self, contribution: PluginSchemaContribution) -> AuthPlugin
pub fn with_rate_limit(self, rule: PluginRateLimitRule) -> AuthPlugin
pub fn with_before_hook<F>(self, path: impl Into<String>, hook: F) -> AuthPluginwhere
F: Fn(&AuthContext, Request<Vec<u8>>) -> Result<PluginBeforeHookAction, RustAuthError> + Send + Sync + 'static,
pub fn with_after_hook<F>(self, path: impl Into<String>, hook: F) -> AuthPluginwhere
F: Fn(&AuthContext, &Request<Vec<u8>>, Response<Vec<u8>>) -> Result<PluginAfterHookAction, RustAuthError> + Send + Sync + 'static,
pub fn with_async_before_hook<F>(
self,
path: impl Into<String>,
hook: F,
) -> AuthPluginwhere
F: for<'a> Fn(&'a AuthContext, Request<Vec<u8>>) -> Pin<Box<dyn Future<Output = Result<PluginBeforeHookAction, RustAuthError>> + Send + 'a>> + Send + Sync + 'static,
pub fn with_async_after_hook<F>( self, path: impl Into<String>, hook: F, ) -> AuthPlugin
Sourcepub fn with_async_after_handler<F, Fut>(
self,
path: impl Into<String>,
handler: F,
) -> AuthPlugin
pub fn with_async_after_handler<F, Fut>( self, path: impl Into<String>, handler: F, ) -> AuthPlugin
Registers an async after-hook without manual Box::pin.
Sourcepub fn with_async_before_handler<F, Fut>(
self,
path: impl Into<String>,
handler: F,
) -> AuthPluginwhere
F: Fn(AuthContext, Request<Vec<u8>>) -> Fut + Send + Sync + Clone + 'static,
Fut: Future<Output = Result<PluginBeforeHookAction, RustAuthError>> + Send + 'static,
pub fn with_async_before_handler<F, Fut>(
self,
path: impl Into<String>,
handler: F,
) -> AuthPluginwhere
F: Fn(AuthContext, Request<Vec<u8>>) -> Fut + Send + Sync + Clone + 'static,
Fut: Future<Output = Result<PluginBeforeHookAction, RustAuthError>> + Send + 'static,
Registers an async before-hook without manual Box::pin.
pub fn with_error_code(self, error_code: PluginErrorCode) -> AuthPlugin
pub fn with_database_hook(self, hook: PluginDatabaseHook) -> AuthPlugin
pub fn with_migration(self, migration: PluginMigration) -> AuthPlugin
pub fn with_password_validator<F>(self, validator: F) -> AuthPluginwhere
F: for<'a> Fn(&'a AuthContext, PluginPasswordValidationInput) -> Pin<Box<dyn Future<Output = Result<(), PluginPasswordValidationRejection>> + Send + 'a>> + Send + Sync + 'static,
pub fn with_state<T>(self, state: T) -> AuthPlugin
pub fn state<T>(&self) -> Option<Arc<T>>
pub fn with_middleware<F>( self, path: impl Into<String>, middleware: F, ) -> AuthPlugin
pub fn with_async_middleware<F>( self, path: impl Into<String>, middleware: F, ) -> AuthPlugin
pub fn with_on_request<F>(self, hook: F) -> AuthPluginwhere
F: Fn(&AuthContext, Request<Vec<u8>>) -> Result<PluginRequestAction, RustAuthError> + Send + Sync + 'static,
pub fn with_on_response<F>(self, hook: F) -> AuthPlugin
Sourcepub fn with_on_response_async<F>(self, hook: F) -> AuthPlugin
pub fn with_on_response_async<F>(self, hook: F) -> AuthPlugin
Async hook run during async response finalization after session hydration
and before synchronous on_response hooks.
Trait Implementations§
Source§impl Clone for AuthPlugin
impl Clone for AuthPlugin
Source§fn clone(&self) -> AuthPlugin
fn clone(&self) -> AuthPlugin
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for AuthPlugin
impl !UnwindSafe for AuthPlugin
impl Freeze for AuthPlugin
impl Send for AuthPlugin
impl Sync for AuthPlugin
impl Unpin for AuthPlugin
impl UnsafeUnpin for AuthPlugin
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