Skip to main content

FileHstsConfig

Struct FileHstsConfig 

Source
pub struct FileHstsConfig {
    pub enabled: Option<bool>,
    pub max_age: Option<u32>,
    pub include_subdomains: Option<bool>,
    pub preload: Option<bool>,
    pub force_replace_backend: Option<bool>,
}
Expand description

HSTS (HTTP Strict Transport Security, RFC 6797) policy as serialised under [https.listeners.default.hsts] (listener default) or [clusters.<id>.frontends.hsts] (per-frontend override).

enabled is REQUIRED whenever the block is present — its presence vs absence disambiguates “preserve current” / “explicit disable” / “enable” on hot-reconfig partial updates.

When enabled = true and max_age is omitted, sozu substitutes DEFAULT_HSTS_MAX_AGE (1 year) at config-load time.

Fields§

§enabled: Option<bool>

REQUIRED. true enables HSTS for this scope; false suppresses any inherited listener default (explicit-disable signal).

§max_age: Option<u32>

Strict-Transport-Security: max-age=<seconds>. Optional — defaults to DEFAULT_HSTS_MAX_AGE when enabled = true. max_age = 0 is the RFC 6797 §11.4 kill switch and is allowed silently; 0 < max_age < 86400 warns at config-load.

§include_subdomains: Option<bool>

Append ; includeSubDomains to the rendered header.

§preload: Option<bool>

Append ; preload to the rendered header. Opt-in only — see RFC 6797 §14.2 and https://hstspreload.org/.

§force_replace_backend: Option<bool>

Operator opt-in to override any backend-supplied Strict-Transport-Security header. RFC 6797 §6.1 default behaviour is to PRESERVE the backend’s value (sozu’s edit uses HeaderEditMode::SetIfAbsent). Set this to true to harden a stale or weak upstream HSTS policy centrally — the materialiser then uses HeaderEditMode::Set, replacing any backend STS with sozu’s rendered value.

Implementations§

Source§

impl FileHstsConfig

Source

pub fn to_proto(&self, scope: &str) -> Result<HstsConfig, ConfigError>

Validate and convert the file-level FileHstsConfig into the proto HstsConfig. scope is a human-readable string (e.g. “listener” or “frontend api/example.com”) surfaced into errors and warnings so the operator can pinpoint the offending block.

Validation:

  • enabled is required when any other field is set (HstsEnabledRequired); the parser returns the typed error so callers can fail fast.
  • enabled = true && max_age = None substitutes DEFAULT_HSTS_MAX_AGE.
  • 0 < max_age < 86400 warns (likely misconfig — sub-day max-age is useful only for testing).
  • preload = true with max_age < DEFAULT_HSTS_MAX_AGE or include_subdomains != Some(true) warns (the Chrome HSTS preload list will reject the host).
  • max_age = 0 is allowed silently (RFC 6797 §11.4 kill switch).

Trait Implementations§

Source§

impl Clone for FileHstsConfig

Source§

fn clone(&self) -> FileHstsConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FileHstsConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for FileHstsConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Hash for FileHstsConfig

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for FileHstsConfig

Source§

fn eq(&self, other: &FileHstsConfig) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for FileHstsConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for FileHstsConfig

Source§

impl StructuralPartialEq for FileHstsConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,