feat: Update-Check für Admins auf der Benutzerseite (#1078)
- Neues Modul update.rs: Versionsvergleich (MAJOR.MINOR.PATCH, v-Präfix, -rcN) und Abfrage der Releases auf git.wlkns.org (feste Adresse, nur lesend, ohne Nutzerdaten). - Benutzerseite: Karte „Version“ mit Knopf „Auf Updates prüfen“, nur Rolle admin, mit CSRF-Prüfung; Ergebnis als Hinweis, Audit-Eintrag system.update_check. - reqwest mit rustls (webpki-roots), damit HTTPS möglich ist; Begründung und Folgen siehe ROADMAP #1078. Binary 6,3 auf 7,6 MB, statisch (musl), neue Abhängigkeit unter anderem ring. - Geprüft: 255 Tests, clippy, fmt; echter Abruf (ignorierter Test) und lokale Instanz per curl: Gitea meldet v0.1.8, Hinweis „aktuell“. Die Installation bleibt beim Menschen. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -280,8 +280,15 @@ pub(super) async fn users_page(
|
||||
})
|
||||
.collect();
|
||||
let dialogs: String = users.iter().map(|u| user_dialog(&viewer, u)).collect();
|
||||
let update = format!(
|
||||
"<section class=\"card\"><h2>Version</h2>\
|
||||
<p>Laufende Version: <code>{}</code>. Die Prüfung fragt Gitea nach dem neuesten Release und ändert nichts auf dem Server.</p>\
|
||||
<form method=\"post\" action=\"/ui/benutzer/update-pruefen\">{}<button type=\"submit\">Auf Updates prüfen</button></form></section>",
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
csrf_field(&viewer),
|
||||
);
|
||||
let body = format!(
|
||||
"{notice}<section class=\"card\"><div class=\"breit\"><table><thead><tr><th>Name</th><th>Rolle</th><th></th></tr></thead>\
|
||||
"{notice}{update}<section class=\"card\"><div class=\"breit\"><table><thead><tr><th>Name</th><th>Rolle</th><th></th></tr></thead>\
|
||||
<tbody>{rows}</tbody></table></div></section>{dialogs}\
|
||||
<section class=\"card\"><h2>Neuen Benutzer anlegen</h2>\
|
||||
<form class=\"formular\" method=\"post\" action=\"/ui/benutzer/anlegen\">{csrf}\
|
||||
@ -342,6 +349,29 @@ fn admin(state: &AppState, headers: &HeaderMap, body: &[u8]) -> Result<Viewer, B
|
||||
guard(state, headers, form_field(body, "csrf").as_deref(), true)
|
||||
}
|
||||
|
||||
/// Update-Check (#1078): nur Admin, nur auf Knopfdruck. Das Ergebnis wird als Hinweis
|
||||
/// (`?m=update_…`) angezeigt; die Adresse der Prüfung ist fest eingebaut.
|
||||
pub(super) async fn update_check(
|
||||
State(state): State<Arc<AppState>>,
|
||||
headers: HeaderMap,
|
||||
body: Bytes,
|
||||
) -> Response {
|
||||
let viewer = match admin(&state, &headers, &body) {
|
||||
Ok(v) => v,
|
||||
Err(response) => return *response,
|
||||
};
|
||||
let (code, ergebnis) = match crate::update::pruefen().await {
|
||||
Ok(Some(tag)) => match crate::update::is_newer(&tag, env!("CARGO_PKG_VERSION")) {
|
||||
Ok(true) => ("update_neu", "neu"),
|
||||
_ => ("update_aktuell", "aktuell"),
|
||||
},
|
||||
Ok(None) => ("update_aktuell", "keine_version"),
|
||||
Err(_) => ("update_fehler", "fehler"),
|
||||
};
|
||||
audit(&state, &viewer, "system.update_check", ergebnis);
|
||||
back("/ui/benutzer", code)
|
||||
}
|
||||
|
||||
pub(super) async fn user_create(
|
||||
State(state): State<Arc<AppState>>,
|
||||
headers: HeaderMap,
|
||||
|
||||
Reference in New Issue
Block a user