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 SecurityPlugin
impl Move for SecurityPlugin
impl Send for SecurityPlugin
impl Sync for SecurityPlugin
impl Unpin for SecurityPlugin
impl UnsafeUnpin for SecurityPlugin
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