#[non_exhaustive]pub struct SecurityHeadersConfig {
pub x_content_type_options: Option<String>,
pub x_frame_options: Option<String>,
pub cache_control: Option<String>,
pub referrer_policy: Option<String>,
pub cross_origin_opener_policy: Option<String>,
pub cross_origin_resource_policy: Option<String>,
pub cross_origin_embedder_policy: Option<String>,
pub permissions_policy: Option<String>,
pub x_permitted_cross_domain_policies: Option<String>,
pub content_security_policy: Option<String>,
pub x_dns_prefetch_control: Option<String>,
pub strict_transport_security: Option<String>,
}Expand description
Per-header overrides for the OWASP security headers emitted by the global response middleware.
Each field follows a three-state semantic:
| Value | Behaviour |
|---|---|
None | Use the built-in default (current behaviour). |
Some("") | Omit the header entirely from responses. |
Some(value) | Emit header: value. Validated at config-load time. |
All non-empty values are validated via
axum::http::HeaderValue::from_str inside
McpServerConfig::validate; invalid values fail fast before the
server starts accepting traffic.
Strict-Transport-Security has an additional rule: the substring
preload (case-insensitive) is rejected. Operators who want to
commit to the HSTS preload list must do so via a future explicit
builder method, not by smuggling it through this knob.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.x_content_type_options: Option<String>Override for X-Content-Type-Options. Default: nosniff.
x_frame_options: Option<String>Override for X-Frame-Options. Default: deny.
cache_control: Option<String>Override for Cache-Control. Default: no-store, max-age=0.
referrer_policy: Option<String>Override for Referrer-Policy. Default: no-referrer.
cross_origin_opener_policy: Option<String>Override for Cross-Origin-Opener-Policy. Default: same-origin.
cross_origin_resource_policy: Option<String>Override for Cross-Origin-Resource-Policy. Default: same-origin.
cross_origin_embedder_policy: Option<String>Override for Cross-Origin-Embedder-Policy. Default: require-corp.
permissions_policy: Option<String>Override for Permissions-Policy. Default:
accelerometer=(), camera=(), geolocation=(), microphone=().
x_permitted_cross_domain_policies: Option<String>Override for X-Permitted-Cross-Domain-Policies. Default: none.
content_security_policy: Option<String>Override for Content-Security-Policy. Default:
default-src 'none'; form-action 'self'; object-src 'none'; frame-ancestors 'none'; upgrade-insecure-requests.
x_dns_prefetch_control: Option<String>Override for X-DNS-Prefetch-Control. Default: off.
strict_transport_security: Option<String>Override for Strict-Transport-Security. Default (TLS only):
max-age=63072000; includeSubDomains. Only emitted when TLS is
active; the override is ignored on plaintext deployments. The
substring preload (any case) is rejected by the validator.
Trait Implementations§
Source§impl Clone for SecurityHeadersConfig
impl Clone for SecurityHeadersConfig
Source§fn clone(&self) -> SecurityHeadersConfig
fn clone(&self) -> SecurityHeadersConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SecurityHeadersConfig
impl Debug for SecurityHeadersConfig
Source§impl Default for SecurityHeadersConfig
impl Default for SecurityHeadersConfig
Source§fn default() -> SecurityHeadersConfig
fn default() -> SecurityHeadersConfig
Source§impl<'de> Deserialize<'de> for SecurityHeadersConfigwhere
SecurityHeadersConfig: Default,
impl<'de> Deserialize<'de> for SecurityHeadersConfigwhere
SecurityHeadersConfig: Default,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.