| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The gate asked whether the request carried `Cookie: auth=1`, and login did
nothing but set that literal value, so the password protected the login form
and nothing else: anyone could read the reviews, the audit log, the settings
and the build logs by typing the cookie themselves, and the CSRF step then
happily minted them a session to POST with. The random sid machinery was
already there and already unguessable; it was just never bound to the flag
that said "someone authenticated".
A session now carries that flag. `auth.rs` holds a map of live sids to
whether they passed the password gate; `authenticate` can only flip a sid this
process minted, so a login attempt cannot mint a session as a side effect.
`gate` asks `is_authenticated(sid)` and nothing else, and the `auth` cookie is
gone from both the login response and the logout one. Login rotates the sid
rather than promoting the anonymous one, so the session that existed before
the password was typed is never the one that carries the privilege after it;
logout drops the sid, which invalidates its derived CSRF token with it.
Two tests, both over a bare socket because a client that follows redirects
turns "you are not signed in" into the login page's 200 and hides the whole
point: `a_forged_auth_cookie_is_not_a_session` (the exact forgery, on every
sensitive surface, GET and POST) and `login_rotates_the_session_and_logout_ends_it`
(rotation, dead pre-login sid, dead logged-out sid). The audit actor is
honest now too: with a password set, only an authenticated session is "web".
|
|
|
§13)
tiny_http, thread-per-connection, askama templates. Every §13 surface is
server-rendered HTML that works with scripts switched off: Inbox, review
detail with the full panel set, Builds, Attention, Index, Subscriptions,
Ops/audit, Settings.
The parts that are easy to get wrong:
- Handlers read through thread-local READ-ONLY connections. They cannot
take the write lock even by accident, so a slow page render never blocks
the build pipeline's writer. tests/http.rs asserts this by trying to
write through a read connection and requiring failure.
- Every POST requires a CSRF token derived from the session id. Logout
drops the session, which invalidates every form still open in a browser.
- Approve carries identity_hash AND diff_digest (§7.1a). If either has
moved, the approval is refused with 409 and the page re-renders the
review AS IT IS NOW — never a silent retarget onto the newer state.
- Bulk approve refuses high-risk items unless each one is individually
confirmed by id. Bulk is per-item, never 'approve everything forever'.
- Reject requires a note; it is re-openable, not a deletion.
- Optional password gate; anonymous visitors are redirected to /login.
Also: the index page states the pacman conf snippet including
'SigLevel = Required DatabaseOptional', because a repo consumers ignore the
signature is a repo that gets MITM'd.
|