docs(progress): update T41-T43 completion status
- Mark T41, T42, T43 as completed with commit reference - Update progress to 52% (38/74 tasks) - Add T41-T43 context to githistory.md - 24 tests with 100% coverage on tokens router
This commit is contained in:
@@ -138,3 +138,70 @@ Test suite completa per l'autenticazione.
|
||||
| **Totale** | 6 commits | 34 | **98.23%** |
|
||||
|
||||
**Prossima fase:** Gestione API Keys (T23-T29)
|
||||
|
||||
---
|
||||
|
||||
## 2026-04-07: API Token Management Phase (T41-T43)
|
||||
|
||||
### feat(tokens): T41-T43 implement API token management endpoints
|
||||
**Commit:** 5e89674
|
||||
|
||||
**Contesto:**
|
||||
Implementazione della gestione token API per l'accesso programmatico alla public API.
|
||||
|
||||
**Motivazione:**
|
||||
- Gli utenti necessitano di token API per accedere alla public API (/api/v1/*)
|
||||
- Sicurezza critica: token plaintext mostrato SOLO alla creazione
|
||||
- Limite di token per utente per prevenire abuse
|
||||
- Soft delete per audit trail
|
||||
|
||||
**Dettagli implementativi:**
|
||||
|
||||
**T41 - POST /api/tokens:**
|
||||
- Auth JWT required
|
||||
- Body: ApiTokenCreate (name: 1-100 chars)
|
||||
- Verifica limite: MAX_API_TOKENS_PER_USER (default 5)
|
||||
- Genera token con generate_api_token() → (plaintext, hash)
|
||||
- Salva SOLO hash SHA-256 nel DB
|
||||
- Ritorna: ApiTokenCreateResponse con token PLAINTEXT (solo questa volta!)
|
||||
- Errori: 400 se limite raggiunto, 422 se nome invalido
|
||||
|
||||
**T42 - GET /api/tokens:**
|
||||
- Auth JWT required
|
||||
- Ritorna: List[ApiTokenResponse] (NO token values!)
|
||||
- Solo token attivi (is_active=True)
|
||||
- Ordinamento: created_at DESC
|
||||
- Filtraggio per user_id (sicurezza: utente vede solo i propri)
|
||||
|
||||
**T43 - DELETE /api/tokens/{id}:**
|
||||
- Auth JWT required
|
||||
- Verifica ownership (403 se token di altro utente)
|
||||
- Soft delete: set is_active = False
|
||||
- Ritorna: 204 No Content
|
||||
- Token revocato non funziona più su API pubblica (401)
|
||||
- Errori: 404 se token non trovato, 403 se non autorizzato
|
||||
|
||||
**Sicurezza implementata:**
|
||||
- ✅ Token plaintext mai loggato
|
||||
- ✅ Solo hash SHA-256 nel database
|
||||
- ✅ Token values mai inclusi in risposte GET
|
||||
- ✅ Verifica ownership su ogni operazione
|
||||
- ✅ Soft delete per audit trail
|
||||
|
||||
**Test:**
|
||||
- 24 test totali
|
||||
- 100% coverage su routers/tokens.py
|
||||
- Test sicurezza critici: NO token values in GET, revoked token fails on public API
|
||||
|
||||
---
|
||||
|
||||
## Riepilogo Fase API Token Management
|
||||
|
||||
| Task | Descrizione | Test | Stato |
|
||||
|------|-------------|------|-------|
|
||||
| T41 | POST /api/tokens (generate) | 8 | ✅ Completato |
|
||||
| T42 | GET /api/tokens (list) | 7 | ✅ Completato |
|
||||
| T43 | DELETE /api/tokens/{id} (revoke) | 9 | ✅ Completato |
|
||||
| **Totale** | | **24** | **100% coverage** |
|
||||
|
||||
**MVP Fase 1 completato al 52%!** 🎉
|
||||
|
||||
@@ -128,19 +128,19 @@
|
||||
- [x] T40: Scrivere test per public API endpoints - ✅ Completato (2026-04-07)
|
||||
- 27 test endpoint + 18 test rate limit + 25 test schemas = 70 test totali
|
||||
- Coverage: public_api.py 100%, rate_limit.py 98%
|
||||
- [x] T41: Implementare POST /api/tokens (generate) - ✅ Completato (2026-04-07)
|
||||
- [x] T41: Implementare POST /api/tokens (generate) - ✅ Completato (2026-04-07, commit: 5e89674)
|
||||
- Endpoint: POST /api/tokens con auth JWT
|
||||
- Limite: MAX_API_TOKENS_PER_USER (default 5)
|
||||
- Token plaintext mostrato SOLO in risposta creazione
|
||||
- Hash SHA-256 salvato nel DB
|
||||
- Test: 8 test passanti, 100% coverage
|
||||
- [x] T42: Implementare GET /api/tokens (list) - ✅ Completato (2026-04-07)
|
||||
- [x] T42: Implementare GET /api/tokens (list) - ✅ Completato (2026-04-07, commit: 5e89674)
|
||||
- Endpoint: GET /api/tokens con auth JWT
|
||||
- NO token values in risposta (sicurezza)
|
||||
- Ordinamento: created_at DESC
|
||||
- Solo token attivi (is_active=True)
|
||||
- Test: 7 test passanti
|
||||
- [x] T43: Implementare DELETE /api/tokens/{id} - ✅ Completato (2026-04-07)
|
||||
- [x] T43: Implementare DELETE /api/tokens/{id} - ✅ Completato (2026-04-07, commit: 5e89674)
|
||||
- Endpoint: DELETE /api/tokens/{id} con auth JWT
|
||||
- Soft delete: is_active=False
|
||||
- Verifica ownership (403 se non proprio)
|
||||
|
||||
Reference in New Issue
Block a user