diff options
Diffstat (limited to 'src/http/mod.rs')
| -rw-r--r-- | src/http/mod.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/http/mod.rs b/src/http/mod.rs index 16ff6b1..07024d8 100644 --- a/src/http/mod.rs +++ b/src/http/mod.rs @@ -5,9 +5,11 @@ //! mutations are handed to the writer actor as a transaction request. That is //! what keeps a slow browser from ever holding the database lock. //! -//! Two guards on every POST: a session cookie, and a CSRF token that must match -//! it. Forms are plain `<form method=post>`, so the whole approval flow works -//! with JavaScript switched off (§12). +//! Two guards on every POST: a session id, and a CSRF token that must match +//! it. The session id is the only credential the browser holds, and it counts +//! as authentication only if someone typed the password into a form on that +//! exact session (§12). Forms are plain `<form method=post>`, so the whole +//! approval flow works with JavaScript switched off. mod auth; mod forms; @@ -232,12 +234,13 @@ fn dispatch(state: &State, req: &Req) -> Res { } // Session gate: mint a session for anonymous visitors so the CSRF token - // exists even before anyone logs in. + // exists even before anyone logs in. It is not a login — `gate` only lets + // through a sid that a successful login marked authenticated. let (sid, new_session) = match req.cookie("sid") { Some(s) if auth::is_valid_session(&s) => (s, false), _ => (auth::new_session(), true), }; - let gated = routes::gate(state, req); + let gated = routes::gate(state, req, &sid); if let Some(mut res) = gated { if new_session { res.header("X-New-Session", &sid); |
