diff options
Diffstat (limited to 'src/http/routes/mod.rs')
| -rw-r--r-- | src/http/routes/mod.rs | 15 |
1 files changed, 0 insertions, 15 deletions
diff --git a/src/http/routes/mod.rs b/src/http/routes/mod.rs index 0dfed52..ed488c8 100644 --- a/src/http/routes/mod.rs +++ b/src/http/routes/mod.rs @@ -8,9 +8,6 @@ use super::{Req, Res, State}; mod mutations; mod pages; -// The handlers live in two files by direction of travel — reads in `pages`, -// writes in `mutations` — and are pulled back into scope here so the routing -// table below still reads as one flat list of endpoints (n-4). pub(crate) use mutations::*; pub(crate) use pages::*; @@ -29,9 +26,6 @@ pub fn login_form(state: &State, req: &Req) -> Res { page_to_res(Login { page, error: String::new() }, 200) } -/// Forget the session server-side and clear the cookie. The CSRF token is -/// derived from the sid, so dropping the sid invalidates every form a browser -/// still has open — which is exactly what logout should do. pub fn logout(req: &Req) -> Res { if let Some(sid) = req.cookie("sid") { auth::drop_session(&sid); @@ -45,9 +39,6 @@ pub fn login(state: &State, req: &Req) -> Res { let given = req.form_get("password").unwrap_or_default(); let page = Page::new("Sign in", csrf(state, req)); if auth::password_ok(&state.cfg, &given) { - // Rotate rather than promote: the sid the visitor arrived with (if any) - // is dropped, so the session that existed before the password was typed - // is never the one that carries the privilege afterwards. if let Some(old) = req.cookie("sid") { auth::drop_session(&old); } @@ -57,7 +48,6 @@ pub fn login(state: &State, req: &Req) -> Res { }; auth::authenticate(&sid); let mut res = Res::redirect("/"); - // `serve` turns this into the `Set-Cookie: sid=…` header. res.header("X-New-Session", &sid); res } else { @@ -109,7 +99,6 @@ fn not_found(state: &State, req: &Req) -> Res { ) } -/// The shared chrome: counts for the nav badges and the active-tab marker. fn chrome(state: &State, req: &Req, title: &str, active: &str) -> Page { let db = &state.db; let mut page = Page::new(title, csrf(state, req)); @@ -133,7 +122,6 @@ fn csrf(_state: &State, req: &Req) -> String { req.cookie("sid").map(|s| auth::csrf_token(&s)).unwrap_or_default() } -/// A byte count a human can read at a glance. fn human_size(bytes: i64) -> String { const UNITS: [&str; 4] = ["B", "KiB", "MiB", "GiB"]; let mut v = bytes as f64; @@ -158,9 +146,6 @@ fn age(detected_at: &str) -> String { format!("{detected_at} → {now}") } -/// Who the audit trail says made a decision. With no password configured the -/// UI is open on loopback and every session is the operator's; with one, only -/// a session that passed the gate gets a name. fn actor(state: &State, req: &Req) -> &'static str { let sid = req.cookie("sid").unwrap_or_default(); if !auth::auth_required(&state.cfg) || auth::is_authenticated(&sid) { |
