[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:
@@ -179,39 +179,77 @@ pub async fn overview(State(st): Shared, headers: HeaderMap) -> Result<Response,
|
||||
acme_configured: true,
|
||||
secrets: m.site().secrets.iter().map(|s| s.to_string()).collect(),
|
||||
watch_seconds: c.cfg.watch_secs,
|
||||
share_links_available: c.share_key.is_some(),
|
||||
share_links_available: c.share_key.is_some() && c.engine_running() != "caddy",
|
||||
});
|
||||
let es = super::pki::engine_view(c);
|
||||
let on_caddy = es.running == "caddy";
|
||||
let caddy_built = std::fs::metadata(&c.cfg.caddy.config)
|
||||
.and_then(|m| m.modified())
|
||||
.ok()
|
||||
.and_then(|t| t.duration_since(std::time::UNIX_EPOCH).ok())
|
||||
.map(|d| rfc3339(d.as_secs()));
|
||||
let caddy_current = tree
|
||||
.as_ref()
|
||||
.and_then(|t| t.model().ok())
|
||||
.and_then(|m| ianitor_core::compile::caddy(&m, &c.cfg.caddy_compile().options()).ok())
|
||||
.is_some_and(|text| {
|
||||
std::fs::read_to_string(&c.cfg.caddy.config).ok().as_deref() == Some(text.as_str())
|
||||
});
|
||||
let ov = Overview {
|
||||
counts,
|
||||
hosts,
|
||||
engine: EngineView {
|
||||
running: "pingora".into(),
|
||||
state: if status.is_some() && error.is_none() {
|
||||
"running"
|
||||
state: if es.state == "switching" {
|
||||
"switching".into()
|
||||
} else if on_caddy || (status.is_some() && error.is_none()) {
|
||||
"running".into()
|
||||
} else {
|
||||
"stopped"
|
||||
}
|
||||
.into(),
|
||||
since: status.as_ref().map(|s| rfc3339(s.started_at)),
|
||||
fallback_ready: None,
|
||||
"stopped".into()
|
||||
},
|
||||
since: if on_caddy || es.state == "switching" {
|
||||
Some(es.since.clone())
|
||||
} else {
|
||||
status.as_ref().map(|s| rfc3339(s.started_at))
|
||||
},
|
||||
running: es.running,
|
||||
target: es.target,
|
||||
switchable: es.switchable,
|
||||
fallback_ready: Some(FallbackReady {
|
||||
built_at: caddy_built,
|
||||
current: caddy_current,
|
||||
}),
|
||||
last_error: es.last_error,
|
||||
notes: es.notes,
|
||||
},
|
||||
last_apply,
|
||||
undo: undo_view(c),
|
||||
active_apply: active,
|
||||
repo: Some(repo_view(c, &head)),
|
||||
intermediate: None,
|
||||
intermediate: super::pki::intermediate_view(c),
|
||||
site,
|
||||
paused: c.paused().map(|p| Blocked {
|
||||
code: "control.paused".into(),
|
||||
message: message("control.paused", &messages::params([("reason", p.message)])),
|
||||
}),
|
||||
health_error: error.filter(|_| c.edge.attached()).map(|_| Blocked {
|
||||
code: "health.unavailable".into(),
|
||||
message: message(
|
||||
"health.unavailable",
|
||||
&messages::params([("engine", "Pingora".into())]),
|
||||
),
|
||||
paused: c.effective_pause().map(|p| {
|
||||
if p.code == "engine.caddy" {
|
||||
Blocked {
|
||||
code: p.code,
|
||||
message: p.message,
|
||||
}
|
||||
} else {
|
||||
Blocked {
|
||||
code: "control.paused".into(),
|
||||
message: message("control.paused", &messages::params([("reason", p.message)])),
|
||||
}
|
||||
}
|
||||
}),
|
||||
// Under Caddy, health is not read (edge is stopped); the chip says Caddy serves.
|
||||
health_error: error
|
||||
.filter(|_| c.edge.attached() && !on_caddy)
|
||||
.map(|_| Blocked {
|
||||
code: "health.unavailable".into(),
|
||||
message: message(
|
||||
"health.unavailable",
|
||||
&messages::params([("engine", "Pingora".into())]),
|
||||
),
|
||||
}),
|
||||
rev: Some(head),
|
||||
};
|
||||
let body = serde_json::to_vec(&ov).map_err(|e| ApiError::internal(e.to_string()))?;
|
||||
@@ -1038,6 +1076,14 @@ async fn mint_inner(
|
||||
ApiError::new(StatusCode::TOO_MANY_REQUESTS, "rate.limited", Params::new()).retry(s)
|
||||
})?;
|
||||
let c = &st.ctl;
|
||||
if c.engine_running() == "caddy" {
|
||||
// G7: Caddy cannot check share links; control does not serve visitors itself.
|
||||
return Err(ApiError::new(
|
||||
StatusCode::CONFLICT,
|
||||
"share.engine_caddy",
|
||||
Params::new(),
|
||||
));
|
||||
}
|
||||
let (_, _, model) = c.head_model()?;
|
||||
let Some(host) = model
|
||||
.hosts()
|
||||
@@ -1278,19 +1324,26 @@ impl Modify for Bearer {
|
||||
overview, list_hosts, get_host, validate_host, create_host, update_host, patch_host, delete_host,
|
||||
retry_certificate, list_applies, get_apply, cancel_apply, history, history_entry, restore_preview,
|
||||
get_undo, undo, restore, push_now, settings, list_tokens, create_token, rename_token, revoke_token,
|
||||
mint_share_link, list_share_links, stop_share_link, stop_all_share_links, health, openapi
|
||||
mint_share_link, list_share_links, stop_share_link, stop_all_share_links, health, openapi,
|
||||
super::pki::get_certs, super::pki::request_device, super::pki::get_request, super::pki::cancel_request,
|
||||
super::pki::get_csr, super::pki::put_certificate, super::pki::renew, super::pki::revoke_device,
|
||||
super::pki::make_bundle, super::pki::download_bundle, super::pki::get_engine, super::pki::switch_engine
|
||||
),
|
||||
components(schemas(
|
||||
HostSpec, HealthCheckSpec, HeaderRuleSpec, HostWrite, HostPatch, UndoBody, RestoreBody, TokenCreate,
|
||||
TokenRename, MintBody, ErrorEnvelope, ErrorBody, ApplyAccepted, ApplyView, ApplyList, Step, WatchHost,
|
||||
Reason, FieldError, Overview, HostList, HostDetail, History, RestorePreview, UndoView, TokenList,
|
||||
TokenView, CreatedToken, ShareLinkList, ShareLinkView, MintedLink, StoppedAll, Settings, RepoView,
|
||||
HealthReport, Done
|
||||
HealthReport, Done, super::pki::CertsView, super::pki::PkiRequestView, super::pki::IntermediateView,
|
||||
super::pki::RootView, super::pki::DeviceView, super::pki::DeviceRequestBody, super::pki::CertificateBody,
|
||||
super::pki::BundleBody, super::pki::BundleView, super::pki::EngineSwitchView, super::pki::EngineBody,
|
||||
FallbackReady
|
||||
)),
|
||||
modifiers(&Bearer),
|
||||
tags(
|
||||
(name = "overview"), (name = "hosts"), (name = "applies"), (name = "history"),
|
||||
(name = "repo"), (name = "settings"), (name = "tokens"), (name = "share-links")
|
||||
(name = "repo"), (name = "settings"), (name = "tokens"), (name = "share-links"),
|
||||
(name = "certs"), (name = "engine")
|
||||
)
|
||||
)]
|
||||
pub struct ApiDoc;
|
||||
|
||||
Reference in New Issue
Block a user