mitbringsl/backend/internal
Tronax 7b1c18590e
Backend Phase B (1/2): password auth + sessions
Argon2id password hashing (PHC format, self-encoded/decoded without an
external lib) with constant-time verification, UserStore (create/get by
email and id) and SessionStore (opaque crypto/rand tokens, SHA-256 hashed
in DB, create/lookup/revoke, last_seen_at bump on lookup).

HTTP layer: Register/Login/Logout handlers + RequireAuth middleware.
Login uses a dummy-hash path so unknown-email and wrong-password yield the
same timing/shape, narrowing user enumeration. Tokens accepted via Bearer
header (native clients) or session cookie (HttpOnly, SameSite=Lax).

Routes wired in api.go: POST /auth/register, /auth/login, /auth/logout.
Verified with go test, go vet and an end-to-end smoke test against a real
PostgreSQL container (register/login/logout/duplicate/short-pw/wrong-pw).

OIDC (Phase B part 2) follows next; the issueSession helper is reused.
2026-08-05 19:05:07 +02:00
..
auth Backend Phase B (1/2): password auth + sessions 2026-08-05 19:05:07 +02:00
config Backend Phase A: foundation, migrations, Docker setup 2026-08-05 15:14:37 +02:00
httpapi Backend Phase B (1/2): password auth + sessions 2026-08-05 19:05:07 +02:00
logging Backend Phase A: foundation, migrations, Docker setup 2026-08-05 15:14:37 +02:00
store Backend Phase A: foundation, migrations, Docker setup 2026-08-05 15:14:37 +02:00