// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. //! The compiled runtime config read by ianitor-edge. Produced only by [`crate::compile::edge`]. //! Edge never decides policy: everything it does is spelled out here. Secret values are never //! part of it, only secret names, resolved by edge from `$CREDENTIALS_DIRECTORY`. use serde::{Deserialize, Serialize}; /// Bumped on any incompatible change; edge refuses other versions. pub const EDGE_CONFIG_VERSION: u32 = 3; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub struct EdgeConfig { pub version: u32, /// Plain-HTTP listener: ACME HTTP-01 challenges and redirects to HTTPS. pub http_listen: String, /// TLS listener serving every host by SNI. pub https_listen: String, /// Port used in HTTP→HTTPS redirects (omitted from `Location` when 443). pub https_port: u16, /// Directory holding Domi certificates as `.crt` / `.key`. pub cert_dir: String, /// Edge state; ACME account and certificates live in `/acme`. pub state_dir: String, /// Access log file (JSON lines). Only hosts with `access_log` enabled write to it. pub access_log: String, pub acme: Option, pub forward_auth: Option, /// Device certificates (mTLS); present when any host has `device_certs`. pub device_certs: Option, /// Peers whose `X-Forwarded-For` is believed (IP addresses); empty: none. #[serde(default, skip_serializing_if = "Vec::is_empty")] pub trusted_proxies: Vec, /// A Unix socket (mode 0660) serving the HTTPS hosts in plain HTTP to a front proxy that /// terminated TLS; its peer is trusted (`X-Forwarded-For` names the client). #[serde(default, skip_serializing_if = "Option::is_none")] pub proxy_socket: Option, /// Sorted by hostname. pub hosts: Vec, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub struct EdgeAcme { pub directory: String, pub email: Option, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub struct EdgeForwardAuth { pub upstream: EdgeUpstream, pub path_and_query: String, pub copy_headers: Vec, /// Removed from every client request on a forward-auth host before the auth check: /// Authelia's four identity headers plus the copy headers. pub strip_headers: Vec, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub struct EdgeUpstream { /// `host:port`, IPv6 in brackets. pub address: String, pub tls: bool, /// Server name for TLS (SNI and certificate check): the host name or IP literal. pub sni: String, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields, rename_all = "snake_case", tag = "source")] pub enum EdgeTls { /// Obtain and renew through ACME; stored under `/acme`. Acme, /// Load from files (Domi CA certificates). Files { cert: String, key: String }, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields, rename_all = "snake_case", tag = "kind")] pub enum EdgeValue { Literal { value: String }, Secret { name: String }, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields, rename_all = "snake_case", tag = "op")] pub enum EdgeHeaderOp { Set { name: String, value: EdgeValue }, Remove { name: String }, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub struct EdgeHealthCheck { pub path: String, pub interval_secs: u32, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub struct EdgeHost { pub hostname: String, pub tls: EdgeTls, pub upstreams: Vec, pub forward_auth: bool, pub websockets: bool, pub request_headers: Vec, pub response_headers: Vec, pub health_check: Option, pub access_log: bool, /// Share-link tokens (see `ianitor_core::share`) let visitors in on this host without /// forward-auth. Checked against the key credential and the revocation file. pub share_links: bool, /// Only visitors with an allowed Domi device certificate get in (403 otherwise). pub device_certs: bool, } /// Where edge finds what it needs to check device certificates. Both files are written by /// control: the CA bundle (the Domi intermediates that issue device certificates) and the /// allow list (every device certificate that is issued and not revoked, PEM). A certificate /// that chains to the bundle but is not on the list is refused in the handshake. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub struct EdgeDeviceCerts { pub ca: String, pub allow: String, }