diff --git a/crates/control/src/api/handlers.rs b/crates/control/src/api/handlers.rs index a1f69dc..3670e49 100644 --- a/crates/control/src/api/handlers.rs +++ b/crates/control/src/api/handlers.rs @@ -128,7 +128,11 @@ fn replay(st: &AppState, s: Stored) -> Response { #[utoipa::path(get, path = "/api/v1/overview", tag = "overview", responses((status = 200, body = Overview), (status = 304, description = "Unchanged since the ETag"), (status = 401, body = ErrorEnvelope)), security(("bearer" = [])))] -pub async fn overview(State(st): Shared, headers: HeaderMap) -> Result { +pub async fn overview( + State(st): Shared, + Extension(actor): Extension, + headers: HeaderMap, +) -> Result { let c = &st.ctl; let (status, error, since) = { let h = c @@ -227,6 +231,7 @@ pub async fn overview(State(st): Shared, headers: HeaderMap) -> Result Result, pub site: Option, pub paused: Option, + /// Why changes are paused: the underlying code (`apply.needs_attention`, `control.files_unwritten`, + /// `repo.unreadable`, `engine.caddy`, …), so the UI can offer the right action. + pub paused_reason: Option, /// Set when control cannot read health from edge (`health.unavailable`). pub health_error: Option, pub rev: Option, + /// Who is looking: the Authelia user (through edge) or the API token's name. + pub viewer: Option, +} + +#[derive(Debug, Clone, Serialize, ToSchema)] +pub struct Viewer { + pub name: String, + /// `authelia` or `token`. + pub via: String, } pub fn added_at(c: &Control, hostname: &str) -> Option { diff --git a/crates/control/src/dev.rs b/crates/control/src/dev.rs index 80b0122..921bda0 100644 --- a/crates/control/src/dev.rs +++ b/crates/control/src/dev.rs @@ -22,11 +22,12 @@ use ianitor_control::util::{hex, random, write_atomic}; /// on the offline machine), and the PKI password credential. Control then works like /// production: it issues server certificates for every `tls = "domi"` host. fn dev_pki(dir: &Path) -> Result<(String, ianitor_core::pki::KeyPair), String> { - let (root, key) = - ianitor_core::pki::create_root(ianitor_control::util::now() as i64).map_err(|e| e.to_string())?; + let (root, key) = ianitor_core::pki::create_root(ianitor_control::util::now() as i64) + .map_err(|e| e.to_string())?; std::fs::write(dir.join("offline-root/domi-root.crt"), &root).map_err(|e| e.to_string())?; let pass = hex(&random::<24>().map_err(|e| e.to_string())?); - write_atomic(&dir.join("creds/pki-password"), pass.as_bytes(), 0o600).map_err(|e| e.to_string())?; + write_atomic(&dir.join("creds/pki-password"), pass.as_bytes(), 0o600) + .map_err(|e| e.to_string())?; Ok((root, key)) }