[control] QC minors: device install links open a page and download on POST (never listed), approve and install failures show on the request and the CLI waits, PBKDF2 floor, private pki dirs or an error, trusted_proxies for a proxy in front, a placeholder keeps the device allow list from being empty (Caddy refuses that)

This commit is contained in:
2026-11-08 11:02:50 +01:00
parent bc336d1188
commit 3bf5fa0e1a
27 changed files with 548 additions and 46 deletions
+12
View File
@@ -89,6 +89,18 @@ pub(super) fn compile(model: &Model, o: &CompileOptions) -> Value {
}),
);
https.insert("protocols".into(), json!(["h1", "h2"]));
if !o.trusted_proxies.is_empty() {
// Like edge: X-Forwarded-For from these peers names the client (logs, `client_ip`).
https.insert(
"trusted_proxies".into(),
json!({
"source": "static",
"ranges": o.trusted_proxies.iter().map(ToString::to_string).collect::<Vec<_>>()
}),
);
https.insert("client_ip_headers".into(), json!(["X-Forwarded-For"]));
https.insert("trusted_proxies_strict".into(), json!(1));
}
if !logged.is_empty() {
let names: Map<String, Value> = logged
.iter()
+1
View File
@@ -34,6 +34,7 @@ pub(super) fn compile(model: &Model, o: &CompileOptions) -> EdgeConfig {
ca: join(&o.cert_dir, DEVICE_CA_FILE),
allow: join(&o.cert_dir, DEVICE_ALLOW_FILE),
}),
trusted_proxies: o.trusted_proxies.iter().map(ToString::to_string).collect(),
forward_auth: site.forward_auth.as_ref().map(|fa| EdgeForwardAuth {
upstream: upstream(&fa.upstream),
path_and_query: fa.path_and_query.clone(),
+4
View File
@@ -44,6 +44,10 @@ pub struct CompileOptions {
/// Caddy admin endpoint on a Unix socket (mode 0660), which control uses to load a changed
/// config while Caddy serves. Takes precedence over `caddy_admin`.
pub caddy_admin_socket: Option<String>,
/// Peers whose `X-Forwarded-For` is believed (a proxy in front, such as Caddy beside
/// Ianitor on loopback): the share-link throttle and the access log then see the real
/// client. Empty (the default): only the connection's own address counts.
pub trusted_proxies: Vec<std::net::IpAddr>,
}
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
+3
View File
@@ -31,6 +31,9 @@ pub struct EdgeConfig {
pub forward_auth: Option<EdgeForwardAuth>,
/// Device certificates (mTLS); present when any host has `device_certs`.
pub device_certs: Option<EdgeDeviceCerts>,
/// Peers whose `X-Forwarded-For` is believed (IP addresses); empty: none.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub trusted_proxies: Vec<String>,
/// Sorted by hostname.
pub hosts: Vec<EdgeHost>,
}
+21
View File
@@ -193,6 +193,27 @@ pub fn create_root(now: i64) -> Result<(String, KeyPair), PkiError> {
Ok((cert.pem(), key))
}
/// Common name of [`no_device_placeholder`].
pub const NO_DEVICE_CN: &str = "Ianitor placeholder: no device is allowed";
/// The allow list's only entry while no device is enrolled. Caddy refuses to load an empty
/// leaf list (and with it the whole config), so the list is never empty: this self-signed
/// certificate's key is dropped right here, so no client can ever present it, and it is not
/// issued by the Domi intermediate, so edge refuses it too.
pub fn no_device_placeholder(now: i64) -> Result<String, PkiError> {
let key = generate_key()?;
let mut p = CertificateParams::default();
p.distinguished_name = dn(NO_DEVICE_CN);
p.is_ca = IsCa::ExplicitNoCa;
p.key_usages = vec![KeyUsagePurpose::DigitalSignature];
p.not_before = time(now - BACKDATE_SECS)?;
p.not_after = time(now + 100 * 365 * DAY)?;
p.serial_number = Some(serial()?);
let cert = p.self_signed(&key.0).map_err(build)?;
drop(key);
Ok(cert.pem())
}
/// A CSR for a new intermediate key (made by control on the server).
pub fn intermediate_csr(key: &KeyPair, cn: &str) -> Result<String, PkiError> {
let mut p = CertificateParams::default();