[control] Domi CA and UI sign-in: intermediate renewal by CSR with manual offline signing, domi host certificates, device requests approved by code, one-time PKCS#12 installs, revocation; Remote-User trusted only with edge's per-boot proof

This commit is contained in:
2026-11-07 23:21:49 +01:00
parent 211b851c3e
commit c18ae154ad
17 changed files with 1300 additions and 54 deletions
+9 -3
View File
@@ -34,6 +34,11 @@ mod unix {
fn routes(doc: &Value) -> Vec<(String, String)> {
let mut out = Vec::new();
for (path, item) in doc["paths"].as_object().unwrap() {
// The one-time device download is the one call without a token: the link is
// the secret (G15). Every other call needs one.
if path.starts_with("/api/v1/device-bundles/") {
continue;
}
for method in ["get", "post", "put", "patch", "delete"] {
if item.get(method).is_some() {
let p = path
@@ -118,14 +123,14 @@ mod unix {
vec![("Authorization".into(), "Bearer ".into())],
"token.unknown",
),
// Identity headers do not authenticate (docs/ui-api.md G14).
// Identity headers without edge's proof are refused (docs/ui-api.md G14).
(
"remote-user".into(),
vec![
("Remote-User".into(), "mark".into()),
("Remote-Groups".into(), "admins".into()),
],
"token.missing",
"ui.no_proof",
),
];
for (what, headers, code) in &cases {
@@ -147,7 +152,8 @@ mod unix {
env.call_with("GET", "/api/v1/nope", &[], None).await.status,
401
);
assert_eq!(env.call_with("GET", "/", &[], None).await.status, 401);
// Outside /api/ only the built UI is served (no data, no token); none is set up here.
assert_eq!(env.call_with("GET", "/", &[], None).await.status, 404);
// A wrong Host header (DNS rebinding) is refused even with a good token.
let auth = format!("Bearer {}", env.token);
+14 -4
View File
@@ -116,7 +116,16 @@ mod unix {
let r2 = env
.call("GET", &format!("/api/v1/pki-requests/{rid}/csr"), None)
.await;
assert_eq!(r2.status, 200);
assert_eq!(
r2.status,
200,
"{}
{}
{}",
r.text,
r2.text,
env.control_log()
);
assert_eq!(r2.text, csr);
let signed = pki::sign_intermediate(&off.root_pem, &off.root_key, &csr, now()).unwrap();
let f = env.dir.join("signed.crt");
@@ -170,7 +179,8 @@ mod unix {
i64::from(pki::SERVER_DAYS) - 1
);
// No root key anywhere control writes.
// No root key anywhere control writes. (The start of a P-256 PKCS#8 body is the same
// for every key, so the unique end is compared.)
let key_pem = off.root_key.serialize_pem();
let body: String = key_pem
.lines()
@@ -181,7 +191,7 @@ mod unix {
let bytes = std::fs::read(&f).unwrap();
let text = String::from_utf8_lossy(&bytes);
assert!(
!text.contains(&body[..40]),
!text.contains(&body[body.len() - 40..]),
"root key material in {}",
f.display()
);
@@ -407,7 +417,7 @@ mod unix {
let p = e.path();
if p.is_dir() {
stack.push(p);
} else {
} else if p.is_file() {
out.push(p);
}
}