diff --git a/.planning/ROADMAP.md b/.planning/ROADMAP.md index 4c55a3e..141f0f5 100644 --- a/.planning/ROADMAP.md +++ b/.planning/ROADMAP.md @@ -58,6 +58,16 @@ Plans: **User-in-loop:** Approve the `users` and `sessions` table schemas (columns, indexes, deletion semantics) before sqlc generation. Approve hash algorithm choice. +**Plans:** 7 plans +Plans: +- [ ] 02-01-PLAN.md — Schema + sqlc + auth-package skeleton (citext + users + sessions, test DB harness) +- [ ] 02-02-PLAN.md — argon2id password hashing (TDD: Hash/Verify with PHC encoding) +- [ ] 02-03-PLAN.md — Session store + cookie + ResolveSession/RequireAuth/RedirectIfAuthed middleware +- [ ] 02-04-PLAN.md — Signup vertical slice (form → validate → hash → InsertUser → session → cookie → redirect) +- [ ] 02-05-PLAN.md — Login vertical slice + in-memory rate limiter (AUTH-07) +- [ ] 02-06-PLAN.md — Logout + protect GET / + layout header logout button +- [ ] 02-07-PLAN.md — Mount gorilla/csrf + @ui.CSRFField templ helper across every form (AUTH-06) + ### Phase 3: Tablos CRUD **Goal:** A logged-in user can list, create, view, edit, and delete their tablos end-to-end through HTMX-driven flows. **Mode:** mvp diff --git a/.planning/phases/02-authentication/02-07-PLAN.md b/.planning/phases/02-authentication/02-07-PLAN.md new file mode 100644 index 0000000..3b9798d --- /dev/null +++ b/.planning/phases/02-authentication/02-07-PLAN.md @@ -0,0 +1,288 @@ +--- +phase: 02-authentication +plan: 07 +type: execute +wave: 6 +depends_on: [01, 03, 04, 05, 06] +files_modified: + - backend/internal/auth/csrf.go + - backend/internal/web/ui/csrf_field.templ + - backend/internal/web/router.go + - backend/internal/web/handlers_auth.go + - backend/internal/web/handlers_auth_test.go + - backend/internal/web/handlers.go + - backend/templates/auth_login.templ + - backend/templates/auth_signup.templ + - backend/templates/auth_form_errors.templ + - backend/templates/layout.templ + - backend/templates/index.templ + - backend/cmd/web/main.go + - backend/.env.example + - backend/go.mod + - backend/go.sum +autonomous: true +requirements: [AUTH-06] +tags: [go, csrf, gorilla, htmx, templ, security-hardening] +must_haves: + truths: + - "gorilla/csrf v1.7.3 middleware is mounted on the chi stack AFTER ResolveSession and BEFORE any route group (D-14, D-24)" + - "csrf.Protect is configured with Secure(env != \"dev\"), SameSite(csrf.SameSiteLaxMode), Path(\"/\"), FieldName(\"_csrf\"), RequestHeader(\"X-CSRF-Token\") (D-14)" + - "The csrf authentication key is a 32-byte value loaded from env SESSION_SECRET; main.go fails fast if it is missing or wrong length (D-15 \"key MUST come from env\")" + - "A reusable templ component ui.CSRFField(token) renders (D-15)" + - "Every templ form (signup, login, login fragment, signup fragment, layout logout) embeds @ui.CSRFField(token) as the first child of