feat: API HTTP authentifiée (chat + review) (v0.20.0)

registerApi : login rate-limité → JWT, puis Bearer obligatoire sur
/api/chat, /api/review (+approve/refuse), /api/state. CORS restreint +
rate-limit. Réutilise ChatService + ReviewService. API activée seulement
si auth configurée (apiAuth). 65 tests (5 via inject), 0 vuln.

Palier de risque : privilégié (surface exposée) — montée seulement si
auth présente ; non exposée tant que .env non renseigné.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Kantin-Petit
2026-06-23 02:13:03 +02:00
parent e322ed1167
commit 26debf2fe0
7 changed files with 331 additions and 8 deletions
+11
View File
@@ -6,6 +6,17 @@ incompatibles. Chaque ligne renvoie à un commit dédié (un artefact = un commi
## [Unreleased]
## [0.20.0] — 2026-06-23
### Added
- `src/api/routes.ts` : API HTTP (`registerApi`) — `POST /api/auth/login`
(rate-limit serré), JWT Bearer sur le reste, `POST /api/chat`, `GET /api/review`,
`POST /api/review/:id/{approve,refuse}`, `GET /api/state`. CORS restreint +
rate-limit global. Réutilise `ChatService` + `ReviewService`.
- Config auth API (`CHLOVA_ADMIN_USER/_PASSWORD_HASH/_TOTP_SECRET/_JWT_SECRET`,
`CHLOVA_WEB_ORIGIN`) + helper `apiAuth()` ; API activée seulement si configurée.
- Câblage `index.ts` (API montée si auth présente). Deps `@fastify/cors`,
`@fastify/rate-limit` épinglées. 5 tests API (inject). 65 tests, 0 vuln.
## [0.19.0] — 2026-06-23 — début Phase 4 (UI : auth + service chat)
### Added
- `src/api/auth.ts` : auth surface exposée — mot de passe scrypt (`node:crypto`),