Phase 10, part 1: users, sessions and form tokens

Schema 32 adds users, memberships and sessions, on both databases.
internal/users keeps accounts (Argon2id passwords), roles and modules,
and sessions whose rows hold only a hash of the cookie's value; they end
after a week unused or 30 days. On the server edition, every page but the
public ones needs a session and sends others to /signin. Every edition's
forms now carry a CSRF token (a cookie repeated in each form, added as
pages render; htmx sends it as a header), besides the same-origin check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 08:49:45 -07:00
co-authored by Claude Opus 5.5
parent d537fb367f
commit 96404a3580
21 changed files with 1475 additions and 21 deletions
+3 -3
View File
@@ -121,7 +121,7 @@ func (s *Server) aiTest(w http.ResponseWriter, r *http.Request) {
if err != nil {
result["Error"] = err.Error()
}
s.fragment(w, "ai", "test-result", result)
s.fragment(w, r, "ai", "test-result", result)
}
// aiModels lists an OpenAI-compatible server's models (htmx fragment).
@@ -139,7 +139,7 @@ func (s *Server) aiModels(w http.ResponseWriter, r *http.Request) {
}
data["Models"] = models
}
s.fragment(w, "ai", "model-list", data)
s.fragment(w, r, "ai", "model-list", data)
}
// --- Secrets forms ---
@@ -311,7 +311,7 @@ func (s *Server) accountsSave(w http.ResponseWriter, r *http.Request) {
for _, n := range s.networks() {
if n.Name == r.PostForm.Get("network") {
n.Saved = true
s.fragment(w, "accounts", "network", n)
s.fragment(w, r, "accounts", "network", n)
return
}
}