pub struct SecurityHeadersConfig {
pub enabled: bool,
pub hsts: Option<HstsConfig>,
pub csp: Vec<CspDirective>,
pub frame_options: Option<String>,
pub content_type_options: Option<String>,
pub xss_protection: Option<String>,
pub referrer_policy: Option<String>,
pub permissions_policy: Option<String>,
pub custom: BTreeMap<String, String>,
}Expand description
The reference security_headers dict: enabled, hsts, csp,
frame_options, content_type_options, xss_protection,
referrer_policy, permissions_policy, and custom.
None in the override fields keeps the class default header (the
reference dict lookup returning no key); a set value overrides it. The
reference’s three-way permissions_policy (“UNSET” sentinel keeps the
default, a falsy value removes the header) resolves the same way:
None keeps the default and an empty string removes the header.
Fields§
§enabled: bool§hsts: Option<HstsConfig>§csp: Vec<CspDirective>§frame_options: Option<String>§content_type_options: Option<String>§xss_protection: Option<String>§referrer_policy: Option<String>§permissions_policy: Option<String>None keeps the class default, Some("") removes the header, any
other value overrides it.
custom: BTreeMap<String, String>Implementations§
Source§impl SecurityHeadersConfig
impl SecurityHeadersConfig
Sourcepub fn reference_default() -> Self
pub fn reference_default() -> Self
The reference SecurityConfig.security_headers default block
(_security_config_fields.py): enabled, HSTS
max-age=31536000+includeSubDomains, no CSP, SAMEORIGIN / nosniff /
1; mode=block / strict-origin-when-cross-origin, the camera and
microphone lockdown Permissions-Policy, no custom headers.
Sourcepub fn validate(&self) -> Result<(), SecurityHeadersError>
pub fn validate(&self) -> Result<(), SecurityHeadersError>
Validate the configured values the way the reference configure()
raises out of _validate_header_name / _validate_header_value:
a custom name must be a non-empty RFC 7230 token, and no configured
value may carry CR/LF, exceed 8192 bytes, or (after sanitization)
keep control characters below 0x20 other than tab.
§Errors
SecurityHeadersError naming the offending header on the first
invalid entry.
Trait Implementations§
Source§impl Clone for SecurityHeadersConfig
impl Clone for SecurityHeadersConfig
Source§impl Debug for SecurityHeadersConfig
impl Debug for SecurityHeadersConfig
Source§impl Default for SecurityHeadersConfig
impl Default for SecurityHeadersConfig
impl Eq for SecurityHeadersConfig
Source§impl PartialEq for SecurityHeadersConfig
impl PartialEq for SecurityHeadersConfig
impl StructuralPartialEq for SecurityHeadersConfig
Auto Trait Implementations§
impl Freeze for SecurityHeadersConfig
impl RefUnwindSafe for SecurityHeadersConfig
impl Send for SecurityHeadersConfig
impl Sync for SecurityHeadersConfig
impl Unpin for SecurityHeadersConfig
impl UnsafeUnpin for SecurityHeadersConfig
impl UnwindSafe for SecurityHeadersConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.