[control] UI socket: with [ui] socket control also serves the API on a 0660 Unix socket and trusts the proof only there; a socket upstream is refused unless it is the admin host on control's own socket; probes under Caddy reach it too

This commit is contained in:
2026-11-10 21:06:56 +01:00
parent 1f5e4a59a0
commit d249bcf9f2
7 changed files with 160 additions and 8 deletions
+35
View File
@@ -680,6 +680,41 @@ impl Control {
})?;
// The UI proof belongs to the [ui] host only (core already demands forward-auth for it).
let ui_host = self.cfg.ui.as_ref().and_then(|u| u.hostname.as_deref());
// A socket upstream likewise: only the [ui] host, and only control's own UI socket (a
// route file must not point edge at any other socket on the machine).
let ui_socket = self
.cfg
.ui
.as_ref()
.and_then(|u| u.socket.as_deref())
.and_then(|p| p.to_str());
for h in model.hosts() {
for (i, u) in h.upstreams.iter().enumerate() {
let Some(path) = u.unix_path() else { continue };
if ui_host == Some(h.hostname.as_str()) && ui_socket == Some(path) {
continue;
}
let p = messages::params([
("hostname", h.hostname.to_string()),
("url", u.to_string()),
]);
let fe = FieldError {
code: "host.upstream.unix_socket".into(),
message: message("host.upstream.unix_socket", &p),
field: Some(format!("upstreams[{i}]")),
params: p.clone(),
detail: None,
};
return Err(Fail {
status: 422,
reason: reason(
"apply.failed.validation",
messages::params([("first_error", fe.message.clone())]),
),
errors: vec![fe],
});
}
}
for h in model.hosts() {
let proof = h.request_headers.iter().any(|r| {
matches!(r, ianitor_core::HeaderRule::Set { value: ianitor_core::HeaderValue::Secret(s), .. } if s.as_str() == ianitor_core::UI_PROOF_SECRET)