[control] Tests first: Domi CA flows through the API (offline-signed intermediate, domi host chains, device approval by code, one-time install, revocation, no root key) and UI sign-in that refuses a forged Remote-User (red)
This commit is contained in:
@@ -48,6 +48,16 @@ pub struct Config {
|
||||
pub compile: Compile,
|
||||
/// Different facts for the Caddy output (only tests need this: both engines side by side).
|
||||
pub compile_caddy: Option<Compile>,
|
||||
/// The Domi CA; without it `tls = "domi"` certificates are expected in `cert_dir` already
|
||||
/// and the certificate screens say the CA is not set up.
|
||||
#[serde(default)]
|
||||
pub pki: Option<PkiConfig>,
|
||||
/// The web UI behind edge (sign-in through Authelia, see docs/api.md).
|
||||
#[serde(default)]
|
||||
pub ui: Option<UiConfig>,
|
||||
/// Switching between Pingora and the Caddy fallback at runtime.
|
||||
#[serde(default)]
|
||||
pub engine: Option<EngineConfig>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@@ -280,3 +290,73 @@ fn empty_model() -> Option<ianitor_core::Model> {
|
||||
)
|
||||
.ok()
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct PkiConfig {
|
||||
/// The Domi root certificate (public; may be a Nix store path). The root key is never on
|
||||
/// the server.
|
||||
pub root_cert: PathBuf,
|
||||
/// Credential with the password that encrypts the intermediate and device keys at rest.
|
||||
#[serde(default = "default_pki_password")]
|
||||
pub password_credential: String,
|
||||
/// How requests are approved: `manual` (`ianitor-control pki approve <code>` on the
|
||||
/// server) until Custos can (docs/custos-ticket.md).
|
||||
#[serde(default = "default_approval")]
|
||||
pub approval: String,
|
||||
/// PBKDF2 iterations for the keys control encrypts (only tests lower it).
|
||||
#[serde(default = "default_kdf")]
|
||||
pub kdf_iterations: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct UiConfig {
|
||||
/// The admin host edge serves the UI on (a host in the routes repository with
|
||||
/// `auth = "forward-auth"`, upstream this API, and the proof header rule). Added to
|
||||
/// `allowed_hosts`; used for device install links.
|
||||
pub hostname: Option<String>,
|
||||
/// Credential holding the per-boot secret edge adds as `X-Ianitor-Proof` on the admin
|
||||
/// host. With it, a request carrying the proof is identified by its `Remote-User`.
|
||||
pub proof_credential: Option<String>,
|
||||
/// The built web UI (served at `/`).
|
||||
pub static_dir: Option<PathBuf>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct EngineConfig {
|
||||
/// Which engine runs at boot: `pingora` or `caddy` (read by the engine-select unit).
|
||||
pub file: PathBuf,
|
||||
/// `systemctl` (through the polkit rule for exactly the two units) or `none`.
|
||||
#[serde(default = "default_units")]
|
||||
pub units: String,
|
||||
#[serde(default = "default_systemctl")]
|
||||
pub systemctl: PathBuf,
|
||||
#[serde(default = "default_edge_unit")]
|
||||
pub edge_unit: String,
|
||||
#[serde(default = "default_caddy_unit")]
|
||||
pub caddy_unit: String,
|
||||
}
|
||||
|
||||
fn default_pki_password() -> String {
|
||||
"pki-password".into()
|
||||
}
|
||||
fn default_approval() -> String {
|
||||
"manual".into()
|
||||
}
|
||||
fn default_kdf() -> u32 {
|
||||
ianitor_core::pki::KEY_KDF_ITERATIONS
|
||||
}
|
||||
fn default_units() -> String {
|
||||
"systemctl".into()
|
||||
}
|
||||
fn default_systemctl() -> PathBuf {
|
||||
PathBuf::from("systemctl")
|
||||
}
|
||||
fn default_edge_unit() -> String {
|
||||
"ianitor-edge.service".into()
|
||||
}
|
||||
fn default_caddy_unit() -> String {
|
||||
"caddy-fallback.service".into()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user