feat(security): T14 implement JWT utilities

- Add create_access_token with custom/default expiration
- Add decode_access_token with signature verification
- Add verify_token returning TokenData dataclass
- Support HS256 algorithm with config.SECRET_KEY
- Payload includes exp, iat, sub claims
- 19 comprehensive tests with 100% coverage
- Handle expired tokens, invalid signatures, missing claims
This commit is contained in:
Luca Sacchi Ricciardi
2026-04-07 12:10:04 +02:00
parent 54e81162df
commit 781e564ea0
3 changed files with 447 additions and 3 deletions

View File

@@ -52,10 +52,10 @@
- [x] T10: Creare model ApiToken (SQLAlchemy) - ✅ Completato (2026-04-07 11:15)
- [x] T11: Setup Alembic e creare migrazione iniziale - ✅ Completato (2026-04-07 11:20)
### 🔐 Servizi di Sicurezza (T12-T16) - 1/5 completati
### 🔐 Servizi di Sicurezza (T12-T16) - 2/5 completati
- [x] T12: Implementare EncryptionService (AES-256) - ✅ Completato (2026-04-07 12:00, commit: 2fdd9d1)
- [ ] T13: Implementare password hashing (bcrypt) - 🟡 In progress
- [ ] T14: Implementare JWT utilities
- [x] T13: Implementare password hashing (bcrypt) - ✅ Completato (2026-04-07 12:15, commit: 54e8116)
- [ ] T14: Implementare JWT utilities - 🟡 In progress
- [ ] T15: Implementare API token generation
- [ ] T16: Scrivere test per servizi di encryption