pub struct SecurityPlugin { /* private fields */ }Expand description
Process-wide SecurityPlugin singleton holding prebuilt headers, guards, and custom rules.
Implementations§
Source§impl SecurityPlugin
Inherent implementation of SecurityPlugin.
impl SecurityPlugin
Inherent implementation of SecurityPlugin.
Sourcepub fn new(config: SecurityConfig, rules: Vec<SharedSecurityRule>) -> Self
pub fn new(config: SecurityConfig, rules: Vec<SharedSecurityRule>) -> Self
Compiles a standalone SecurityPlugin instance (useful for direct invocation or testing).
§Arguments
SecurityConfig- Security headers, CSRF, and guard settings.Vec<SharedSecurityRule>- Additional custom security inspection rules.
§Returns
Self- Compiled security engine.
Sourcepub fn init(config: SecurityConfig) -> &'static Self
pub fn init(config: SecurityConfig) -> &'static Self
Initializes the global SecurityPlugin once with config.
§Arguments
SecurityConfig- Security hardening configuration.
§Returns
&'static Self- Reference to the initialized global plugin.
Sourcepub fn init_with_rules(
config: SecurityConfig,
rules: Vec<SharedSecurityRule>,
) -> &'static Self
pub fn init_with_rules( config: SecurityConfig, rules: Vec<SharedSecurityRule>, ) -> &'static Self
Initializes the global SecurityPlugin once with config and custom SecurityRule hooks.
§Arguments
SecurityConfig- Security hardening configuration.Vec<SharedSecurityRule>- Custom request security rules.
§Returns
&'static Self- Reference to the initialized global plugin.
Sourcepub fn get() -> Option<&'static Self>
pub fn get() -> Option<&'static Self>
Returns the initialized global SecurityPlugin, if initialized.
§Returns
Option<&'static Self>- Reference to the global plugin, orNone.
Sourcepub fn get_config(&self) -> &SecurityConfig
pub fn get_config(&self) -> &SecurityConfig
Sourcepub fn inspect_request(&self, ctx: &Context) -> Result<(), SecurityViolation>
pub fn inspect_request(&self, ctx: &Context) -> Result<(), SecurityViolation>
Sourcepub fn apply_headers(&self, response: &mut Response)
pub fn apply_headers(&self, response: &mut Response)
Applies prebuilt security headers onto response and optionally strips X-Powered-By.
§Arguments
&mut Response- Outgoing HTTP response.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for SecurityPlugin
impl !UnwindSafe for SecurityPlugin
impl Forget for SecurityPlugin
impl Freeze for SecurityPluginwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<String>: Freeze,
*const ArcInner<Vec<(&'static str, String)>> is !null: Freeze,
PhantomData<ArcInner<Vec<(&'static str, String)>>>: Freeze,
*const ArcInner<Vec<Arc<dyn SecurityRule>>> is !null: Freeze,
PhantomData<ArcInner<Vec<Arc<dyn SecurityRule>>>>: Freeze,
impl Move for SecurityPlugin
impl Send for SecurityPlugin
impl Sync for SecurityPlugin
impl Unpin for SecurityPlugin
impl UnsafeUnpin for SecurityPluginwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
*const ArcInner<Vec<(&'static str, String)>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Vec<(&'static str, String)>>>: UnsafeUnpin,
*const ArcInner<Vec<Arc<dyn SecurityRule>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Vec<Arc<dyn SecurityRule>>>>: UnsafeUnpin,
Blanket Implementations§
impl<T> AnySend for T
impl<T> AnySendClone for T
impl<T> AnySendSync for T
impl<T> AnySendSyncClone for T
impl<T> AnySync for T
impl<T> AnySyncClone for T
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