[control] Mark's UI decisions: Remote-Name shown with the proof, [ui] logout_url for Sign out, openssl signing files for the manual intermediate step, engine.not_ready, server sentences for the eight generic codes

This commit is contained in:
2026-11-07 23:48:43 +01:00
parent 3e326e85a0
commit 9933f55242
11 changed files with 225 additions and 13 deletions
+44 -6
View File
@@ -86,6 +86,8 @@ pub struct PkiRequestView {
pub message: String,
/// The command that approves it on the server (manual approval).
pub approve_command: Option<String>,
/// Renewals: the base name of the files (`<base>.csr`, `<base>.ext`, `<base>.crt`).
pub file_base: Option<String>,
/// Why it failed, when it did.
pub problem: Option<String>,
}
@@ -141,15 +143,24 @@ pub fn request_view(c: &Control, r: &Request) -> PkiRequestView {
message: message_text,
approve_command: (r.state == "waiting" && manual).then(|| {
if r.kind == "intermediate" {
"ianitor-control ca sign --root <offline root dir> --csr request.csr --out intermediate.crt; then ianitor-control pki install intermediate.crt".to_owned()
ianitor_core::pki::openssl_sign_command(&file_base(r))
} else {
format!("ianitor-control pki approve {}", r.match_code)
}
}),
file_base: (r.kind == "intermediate").then(|| file_base(r)),
problem: r.error.clone(),
}
}
/// `domi-intermediate-2026-11-07`, from the day the request was made.
pub fn file_base(r: &Request) -> String {
format!(
"domi-intermediate-{}",
rfc3339(r.created_at).get(..10).unwrap_or("request")
)
}
#[derive(Debug, Clone, Serialize, ToSchema)]
pub struct IntermediateView {
/// `ok`, `due` (≤ 30 days), `urgent` (≤ 7 days), `expired` or `missing`.
@@ -384,19 +395,19 @@ pub async fn get_csr(State(st): Shared, Path(id): Path<String>) -> Result<Respon
let csr = blocking(&st, move |c| {
pki(c)?
.request(&id, now())?
.and_then(|r| r.csr_pem)
.and_then(|r| r.csr_pem.clone().map(|c| (c, file_base(&r))))
.ok_or(PkiFail::Code("pki.request_not_found"))
})
.await?;
let (csr, base) = csr;
let mut r = csr.into_response();
r.headers_mut().insert(
header::CONTENT_TYPE,
HeaderValue::from_static("application/pkcs10"),
);
r.headers_mut().insert(
header::CONTENT_DISPOSITION,
HeaderValue::from_static("attachment; filename=\"ianitor-intermediate.csr\""),
);
if let Ok(v) = HeaderValue::from_str(&format!("attachment; filename=\"{base}.csr\"")) {
r.headers_mut().insert(header::CONTENT_DISPOSITION, v);
}
Ok(r)
}
@@ -685,3 +696,30 @@ pub async fn switch_engine(
log::info!(target: "ianitor::engine", "switch to {} asked by {}", engine_name(&target), actor.token_id);
Ok(json(StatusCode::ACCEPTED, &engine_view(&st.ctl)))
}
/// The openssl extensions file for signing a renewal by hand (the same profile Custos will
/// use; docs/pki.md).
#[utoipa::path(get, path = "/api/v1/pki-requests/{id}/ext", tag = "certs",
responses((status = 200, description = "openssl -extfile"), (status = 404, body = super::views::ErrorEnvelope)), security(("bearer" = [])))]
pub async fn get_ext(State(st): Shared, Path(id): Path<String>) -> Result<Response, ApiError> {
if !plain_id(&id) {
return Err(not_found("pki.request_not_found"));
}
let r = blocking(&st, move |c| {
pki(c)?
.request(&id, now())?
.filter(|r| r.kind == "intermediate")
.ok_or(PkiFail::Code("pki.request_not_found"))
})
.await?;
let mut resp = ianitor_core::pki::INTERMEDIATE_OPENSSL_EXT.into_response();
resp.headers_mut().insert(
header::CONTENT_TYPE,
HeaderValue::from_static("text/plain; charset=utf-8"),
);
if let Ok(v) = HeaderValue::from_str(&format!("attachment; filename=\"{}.ext\"", file_base(&r)))
{
resp.headers_mut().insert(header::CONTENT_DISPOSITION, v);
}
Ok(resp)
}