Skip to main content

HstsConfig

Struct HstsConfig 

Source
pub struct HstsConfig {
    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 attached to an HTTPS listener default or per-frontend. The materialised Strict-Transport-Security: max-age=N[; includeSubDomains][; preload] header is injected on every successful HTTPS response (including proxy-generated 3xx/401/5xx default answers). Per RFC 6797 §7.2 the header MUST NOT be emitted on plaintext-HTTP responses; sozu rejects HSTS configured on an HttpListenerConfig at config-load time and gates the runtime injection on context.protocol == Protocol::HTTPS.

Validation:

  • enabled = true with max_age = None defaults max_age to 31536000 seconds (1 year) at config-load.
  • max_age = 0 is the RFC 6797 §11.4 kill-switch and is allowed silently; 0 < max_age < 86400 warns.
  • preload = true with max_age < 31536000 or include_subdomains != true warns (Chrome HSTS preload list prerequisites at https://hstspreload.org/).
  • preload is opt-in only; never default-true (RFC 6797 §14.2 — removal from the preload list is slow and partial).

Fields§

§enabled: Option<bool>

Whether HSTS is enabled for this scope. Required whenever the parent message includes an HstsConfig — the partial-update path treats enabled = false as the explicit-disable signal.

§max_age: Option<u32>

Strict-Transport-Security max-age directive in seconds. When enabled = true and this is unset, sozu substitutes 31536000 (1 year, HSTS preload list minimum) 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 with sozu’s typed policy.

RFC 6797 §6.1 default behaviour is to PRESERVE a backend-emitted STS header when one is already present (sozu’s HSTS edit uses HeaderEditMode::SetIfAbsent). That keeps the backend’s intent intact for upstreams that ship their own HSTS policy.

Set this to true for the harden-centrally case: backends behind sozu emit a stale or weak HSTS policy (e.g. legacy max-age=300) and the operator wants to enforce a stronger policy at the proxy edge unconditionally. The materialiser then uses HeaderEditMode::Set instead of SetIfAbsent, replacing every backend-supplied STS header with sozu’s rendered value.

Cite: https://datatracker.ietf.org/doc/html/rfc6797#section-6.1

Implementations§

Source§

impl HstsConfig

Source

pub fn enabled(&self) -> bool

Returns the value of enabled, or the default value if enabled is unset.

Source

pub fn max_age(&self) -> u32

Returns the value of max_age, or the default value if max_age is unset.

Source

pub fn include_subdomains(&self) -> bool

Returns the value of include_subdomains, or the default value if include_subdomains is unset.

Source

pub fn preload(&self) -> bool

Returns the value of preload, or the default value if preload is unset.

Source

pub fn force_replace_backend(&self) -> bool

Returns the value of force_replace_backend, or the default value if force_replace_backend is unset.

Trait Implementations§

Source§

impl Clone for HstsConfig

Source§

fn clone(&self) -> HstsConfig

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 Copy for HstsConfig

Source§

impl Debug for HstsConfig

Source§

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

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

impl Default for HstsConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for HstsConfig

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 Eq for HstsConfig

Source§

impl Hash for HstsConfig

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 Message for HstsConfig

Source§

fn encoded_len(&self) -> usize

Returns the encoded length of the message without a length delimiter.
Source§

fn clear(&mut self)

Clears the message, resetting all fields to their default.
Source§

fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message to a buffer. Read more
Source§

fn encode_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message to a newly allocated buffer.
Source§

fn encode_length_delimited( &self, buf: &mut impl BufMut, ) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message with a length-delimiter to a buffer. Read more
Source§

fn encode_length_delimited_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message with a length-delimiter to a newly allocated buffer.
Source§

fn decode(buf: impl Buf) -> Result<Self, DecodeError>
where Self: Default,

Decodes an instance of the message from a buffer. Read more
Source§

fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>
where Self: Default,

Decodes a length-delimited instance of the message from the buffer.
Source§

fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>
where Self: Sized,

Decodes an instance of the message from a buffer, and merges it into self. Read more
Source§

fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>
where Self: Sized,

Decodes a length-delimited instance of the message from buffer, and merges it into self.
Source§

impl Ord for HstsConfig

Source§

fn cmp(&self, other: &HstsConfig) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for HstsConfig

Source§

fn eq(&self, other: &HstsConfig) -> 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 PartialOrd for HstsConfig

Source§

fn partial_cmp(&self, other: &HstsConfig) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for HstsConfig

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 StructuralPartialEq for HstsConfig

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> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

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

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> Reset for T
where T: Default + Clone,

Source§

fn reset(&mut self)

Source§

impl<T> Reset for T
where T: Default + Clone,

Source§

fn reset(&mut self)

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