Add auth plan to TASKS

This commit is contained in:
2026-01-29 00:48:17 +01:00
parent 4774507142
commit ca25d4f0ee

View File

@@ -1,46 +1,10 @@
# CoopGameChooser Task List
- [x] Initialize git repository.
## Foundation
- [x] Add `.gitignore` for .NET / IIS publish artifacts.
- [x] Scaffold .NET 10 minimal API project with static file hosting (`wwwroot`).
- [x] Configure SQLite connection pointing to `App_Data` with EF Core migrations folder under `Data/`.
- [x] Define domain models in `Domain/`: `Player`, `Suggestion`, `Vote`, `AppState`, `Phase` enum.
- [x] Implement `AppDbContext` in `Data/` with DbSets and simple seeding of `AppState`.
## Identity & Middleware
- [x] Middleware to issue/read HttpOnly `player` cookie with Guid; SameSite=Strict; secure in production.
- [x] Minimal API helpers to resolve current player and ensure existence in DB.
- [x] Global exception handling and basic logging.
## Phase Enforcement
- [x] Store current phase in `AppState`; default to Suggest.
- [x] Central guard ensuring endpoints respect allowed phase (server-side blindness, no client trust).
## API Endpoints (see API.md)
- [x] `GET /api/state` returns phase and counts.
- [x] `GET /api/me` and `POST /api/me/name` to set display name.
- [x] Suggestion endpoints: mine/create/all with per-player visibility rules.
- [x] Vote endpoints: mine/create with per-player visibility and phase gating.
- [x] Results endpoint aggregates totals and vote counts (optionally averages) sorted desc.
- [x] Admin endpoints: switch phase, reset data; protect via env password.
## Frontend (wwwroot)
- [x] `index.html` shell with phase-driven sections.
- [x] `app.js` API client, polling, and render functions per phase; enforce blindness in UI.
- [x] `styles.css` basic responsive layout (desktop + mobile).
## Persistence & Migrations
- [x] Create initial EF Core migration for SQLite schema.
- [x] Add startup migration application.
## Testing & Quality
- [x] Happy-path smoke test script (manual or minimal automated) for phase flow.
- [x] Lint/format via `dotnet format` (optional) and ensure build succeeds.
## Deployment
- [x] Add minimal publish profile/notes for IIS (respect `ASPNETCORE_ENVIRONMENT`, admin password env var, writable App_Data).
## Stretch (removed for now)
*(none)*
## Auth overhaul — username/password instead of random cookie
- [ ] Data model: add username + password hash/salt to `Player` (or a tiny `Account` table), enforce unique username, update `AppDbContext` config and create an EF migration; ensure factory reset seeds stay valid.
- [ ] Cookie pipeline: refactor `UsePlayerIdentity` into a reader that only trusts existing `player` cookies; add helper to issue/clear the cookie after login/register while keeping HttpOnly/SameSite/Secure semantics.
- [ ] Auth endpoints: add `/api/auth/register`, `/api/auth/login`, `/api/auth/logout`; registration should create the player, set the `player` cookie, and store display name; login validates password and reissues cookie; logout clears cookie.
- [ ] Endpoint auth guard: replace `GetOrCreatePlayer` with a `GetAuthenticatedPlayer` helper that returns 401 when unauthenticated; update all suggest/vote/state endpoints to depend on an authenticated player without creating one implicitly.
- [ ] Frontend UX: add login/register screen shown when `/api/me` returns 401; on success hide auth pane, preload name, then refresh phase data; include a logout control to clear local state.
- [ ] Docs: update `API.md` (and `SPEC.md` if needed) to document new auth flows, required auth for existing endpoints, and cookie token behavior.
- [ ] Ops/migration notes: generate/apply migration, note upgrade path for existing random-ID players (likely reset or manual backfill), and verify IIS/base-path configs still work.