Refactor: Backend Frontend-Centric Auth - Suppression OIDC, validation JWT

Architecture modifiée pour Frontend-Centric Authentication:

1. **Suppression des dépendances OIDC**
   - quarkus-oidc → quarkus-smallrye-jwt
   - quarkus-keycloak-authorization → quarkus-smallrye-jwt-build
   - Le backend ne gère plus l'authentification OAuth

2. **Configuration JWT simple**
   - Validation des tokens JWT envoyés par le frontend
   - mp.jwt.verify.publickey.location (JWKS de Keycloak)
   - mp.jwt.verify.issuer (Keycloak realm)
   - Authentification via Authorization: Bearer header

3. **Suppression configurations OIDC**
   - application.properties: Suppression %dev.quarkus.oidc.*
   - application.properties: Suppression %prod.quarkus.oidc.*
   - application-prod.properties: Remplacement par mp.jwt.*
   - Logging: io.quarkus.oidc → io.quarkus.smallrye.jwt

4. **Sécurité simplifiée**
   - quarkus.security.auth.proactive=false
   - @Authenticated sur les endpoints
   - CORS configuré pour le frontend
   - Endpoints publics: /q/*, /openapi, /swagger-ui/*

Flux d'authentification:
1️⃣ Frontend → Keycloak (OAuth login)
2️⃣ Frontend ← Keycloak (access_token)
3️⃣ Frontend → Backend (Authorization: Bearer token)
4️⃣ Backend valide le token JWT (signature + issuer)
5️⃣ Backend → Frontend (données API)

Avantages:
 Pas de secret backend à gérer
 Pas de client btpxpress-backend dans Keycloak
 Séparation claire frontend/backend
 Backend devient une API REST stateless
 Tokens gérés par le frontend (localStorage/sessionStorage)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
DahoudG
2025-10-31 17:05:11 +00:00
parent 7a72d13ffa
commit 7df5f346f1
60 changed files with 6095 additions and 4932 deletions

363
TODOLIST_AUDIT.md Normal file
View File

@@ -0,0 +1,363 @@
# 📋 TODOLIST ULTRA DÉTAILLÉE - AUDIT COMPLET BTPXPRESS SERVER
**Date** : 2025-01-XX
**Status** : En cours d'analyse
---
## 🎯 RÉSUMÉ EXÉCUTIF
**Concepts documentés** : 22
**Entités JPA existantes** : 47
**Services implémentés** : 33
**Resources REST** : ~40 (éparpillées sur adapter/http, application/rest, presentation/rest, presentation/controller)
---
## 📊 MAPPING CONCEPTS vs IMPLÉMENTATIONS
### 1. CHANTIER ✅
- **Entité** : `Chantier.java`
- **Service** : `ChantierService.java`
- **Repository** : `ChantierRepository.java`
- **Resource** : `ChantierResource.java` Cadapter/http) ✅
- **Controller** : `ChantierController.java` Cadapter/controller) ✅
- **DTO** : `ChantierCreateDTO.java`
- **Mapper** : `ChantierMapper.java`
- **Status** : ✅ COMPLET
### 2. CLIENT ✅
- **Entité** : `Client.java`
- **Service** : `ClientService.java`
- **Repository** : `ClientRepository.java`
- **Resource** : `ClientResource.java` Cadapter/http) ✅
- **DTO** : `ClientCreateDTO.java`
- **Mapper** : `ClientMapper.java`
- **Status** : ✅ COMPLET
### 3. MATERIEL ✅
- **Entité** : `Materiel.java`, `MaterielBTP.java`
- **Service** : `MaterielService.java`
- **Repository** : `MaterielRepository.java`
- **Resource** : `MaterielResource.java` Cadapter/http) ✅
- **Controller** : `MaterielController.java` Cadapter/controller) ✅
- **Status** : ✅ COMPLET
### 4. RESERVATION_MATERIEL ✅
- **Entité** : `ReservationMateriel.java`
- **Service** : `ReservationMaterielService.java`
- **Repository** : `ReservationMaterielRepository.java`
- **Resource** : `ReservationMaterielResource.java` Cadapter/rest) ✅
- **Status** : ✅ COMPLET
### 5. LIVRAISON ✅
- **Entité** : `LivraisonMateriel.java`
- **Service** : `LivraisonMaterielService.java`
- **Repository** : `LivraisonMaterielRepository.java` Cadapter/repository) ✅
- **Resource** : `LivraisonMaterielResource.java` Cadapter/rest) ✅
- **Status** : ✅ COMPLET
### 6. FOURNISSEUR ✅
- **Entité** : `Fournisseur.java`, `FournisseurMateriel.java`, `CatalogueFournisseur.java`
- **Service** : `FournisseurService.java`
- **Repository** : `FournisseurRepository.java`
- **Resource** : `FournisseurResource.java` Cadapter/rest) ✅
- **DTO** : `FournisseurDTO.java`
- **Status** : ✅ COMPLET
### 7. STOCK ✅
- **Entité** : `Stock.java`, `CategorieStock.java`, `SousCategorieStock.java`
- **Service** : `StockService.java`
- **Repository** : `StockRepository.java`
- **Controller** : `StockController.java` Cadapter/controller) ✅
- **Status** : ✅ COMPLET
### 8. BON_COMMANDE ✅
- **Entité** : `BonCommande.java`, `LigneBonCommande.java`
- **Service** : `BonCommandeService.java`, `LigneBonCommandeService.java`
- **Repository** : `BonCommandeRepository.java`
- **Controller** : `BonCommandeController.java` Cadapter/controller) ✅
- **Status** : ✅ COMPLET
### 9. DEVIS ✅
- **Entité** : `Devis.java`, `LigneDevis.java`
- **Service** : `DevisService.java`
- **Repository** : `DevisRepository.java`
- **Resource** : `DevisResource.java` Cadapter/http) ✅
- **Status** : ✅ COMPLET
### 10. BUDGET ✅
- **Entité** : `Budget.java`
- **Service** : `BudgetService.java`
- **Repository** : `BudgetRepository.java`
- **Resource** : `BudgetResource.java` Cadapter/http) ✅
- **Status** : ✅ COMPLET
### 11. EMPLOYE ✅
- **Entité** : `Employe.java`, `EmployeCompetence.java`
- **Service** : `EmployeService.java`
- **Repository** : `EmployeRepository.java`
- **Resource** : `EmployeResource.java` Cadapter/http) ✅
- **Controller** : `EmployeController.java` Cadapter/controller) ✅
- **Status** : ✅ COMPLET
### 12. MAINTENANCE ✅
- **Entité** : `MaintenanceMateriel.java`
- **Service** : `MaintenanceService.java`
- **Repository** : `MaintenanceRepository.java`
- **Resource** : `MaintenanceResource.java` Cadapter/http) ✅
- **Status** : ✅ COMPLET
### 13. PLANNING ✅
- **Entité** : `PlanningEvent.java`, `PlanningMateriel.java`, `VuePlanning.java`
- **Service** : `PlanningService.java`, `PlanningMaterielService.java`
- **Repository** : `PlanningEventRepository.java`, `PlanningMaterielRepository.java` Cadapter/repository) ✅
- **Resource** : `PlanningResource.java` Cadapter/http), `PlanningMaterielResource.java` Cadapter/rest) ✅
- **Status** : ✅ COMPLET
### 14. DOCUMENT ✅
- **Entité** : `Document.java`
- **Service** : `DocumentService.java`
- **Repository** : `DocumentRepository.java`
- **Resource** : `DocumentResource.java` Cadapter/http) ✅
- **Status** : ✅ COMPLET
### 15. MESSAGE ✅
- **Entité** : `Message.java`
- **Service** : `MessageService.java`
- **Repository** : `MessageRepository.java`
- **Resource** : `MessageResource.java` Cadapter/http) ✅
- **Status** : ✅ COMPLET
### 16. NOTIFICATION ✅
- **Entité** : `Notification.java`
- **Service** : `NotificationService.java`
- **Repository** : `NotificationRepository.java`
- **Resource** : `NotificationResource.java` Cadapter/http) ✅
- **Status** : ✅ COMPLET
### 17. USER ✅
- **Entité** : `User.java`, `UserRole.java`, `UserStatus.java`
- **Service** : `UserService.java`
- **Repository** : `UserRepository.java`
- **Resource** : `UserResource.java` Cadapter/rest) ✅
- **Resource Auth** : `AuthResource.java` Cadapter/http) ✅
- **Status** : ✅ COMPLET
### 18. ENTREPRISE ⚠️
- **Entité** : `EntrepriseProfile.java`, `AvisEntreprise.java`
- **Service** : ❌ MANQUANT
- **Repository** : ❌ MANQUANT (utilise PanacheEntityBase)
- **Resource** : ❌ MANQUANT
- **Status** : ⚠️ PARTIEL
### 19. DISPONIBILITE ✅
- **Entité** : `Disponibilite.java`
- **Service** : `DisponibiliteService.java`
- **Repository** : `DisponibiliteRepository.java`
- **Resource** : `DisponibiliteResource.java` Cadapter/http) ✅
- **Status** : ✅ COMPLET
### 20. ZONE_CLIMATIQUE ✅ NOUVEAU
- **Entité** : `ZoneClimatique.java`, `SaisonClimatique.java`, `PaysZoneClimatique.java`, `AdaptationClimatique.java`
- **Service** : `ZoneClimatiqueService.java` ✅ NOUVEAU
- **Repository** : `ZoneClimatiqueRepository.java`
- **Resource** : `ZoneClimatiqueResource.java` ✅ NOUVEAU
- **Status** : ✅ COMPLET
### 21. ABONNEMENT ❌
- **Entité** : ❌ MANQUANT (présent dans documentation mais pas implémenté)
- **Service** : ❌ MANQUANT
- **Repository** : ❌ MANQUANT
- **Resource** : ❌ MANQUANT
- **Status** : ❌ NON IMPLÉMENTÉ
### 22. SERVICES_TRANSVERSES ✅
- **Calculateur** : `CalculateurTechniqueBTP.java`
- **Dashboard** : `DashboardResource.java` Cadapter/http) ✅
- **Reports** : `ReportResource.java` Cadapter/http) ✅
- **Statistics** : `StatisticsService.java`
- **Photos** : `PhotoResource.java` Cadapter/http) ✅
- **Health** : `HealthResource.java` Cadapter/http) ✅
- **Comparaison Fournisseurs** : `ComparaisonFournisseurResource.java` Cadapter/rest) ✅
- **Permission** : `PermissionResource.java` Cadapter/rest) ✅
- **Status** : ✅ COMPLET
---
## 🚨 PROBLÈMES IDENTIFIÉS
### A. ORGANISATION DES RESSOURCES (CRITIQUE)
**PROBLÈME** : Les Resources sont éparpillées dans 4 endroits différents
- `adapter/http/` : 23 fichiers
- `application/rest/` : 5 fichiers
- `presentation/rest/` : 5 fichiers
- `presentation/controller/` : 7 fichiers
🔧 **ACTION REQUISE** : Standardiser l'organisation des Resources
- Option 1 : Tout dans `adapter/http/` (recommandé)
- Option 2 : Tout dans `application/rest/`
- Option 3 : Définir clairement les responsabilités
### B. ENTITÉS MANQUANTES
1.`Abonnement.java` - Documenté mais non implémenté
2. ⚠️ `EntrepriseProfile` - Entité existante mais pas de Service/Resource
### C. ENDPOINTS MANQUANTS PAR CONCEPT
#### 18. ENTREPRISE ❌
- Pas de `EntrepriseProfileService`
- Pas de `EntrepriseResource`
- Endpoints à créer :
- `GET /api/v1/entreprises` - Liste des profils
- `GET /api/v1/entreprises/{id}` - Détails profil
- `POST /api/v1/entreprises` - Créer profil
- `PUT /api/v1/entreprises/{id}` - Modifier profil
- `GET /api/v1/entreprises/{id}/avis` - Avis sur entreprise
- `POST /api/v1/entreprises/{id}/avis` - Ajouter avis
- `GET /api/v1/entreprises/{id}/stats` - Statistiques entreprise
#### 21. ABONNEMENT ❌
- Créer entité `Abonnement.java`
- Créer `AbonnementService.java`
- Créer `AbonnementRepository.java`
- Créer `AbonnementResource.java`
- Endpoints à créer :
- `GET /api/v1/abonnements` - Liste abonnements
- `GET /api/v1/abonnements/{id}` - Détails abonnement
- `POST /api/v1/abonnements` - Créer abonnement
- `PUT /api/v1/abonnements/{id}` - Modifier abonnement
- `GET /api/v1/abonnements/plans` - Plans disponibles
- `POST /api/v1/abonnements/{id}/renouveler` - Renouveler
### D. DTO ET MAPPERS MANQUANTS
- ❌ Pas de DTO pour Devis
- ❌ Pas de DTO pour Facture
- ❌ Pas de DTO pour Budget
- ❌ Pas de DTO pour Employe
- ❌ Pas de DTO pour Materiel
- ❌ Pas de DTO pour la plupart des concepts
- ⚠️ Seuls Chantier et Client ont des DTO complets
---
## 📝 TODOLIST DÉTAILLÉE PAR PRIORITÉ
### 🔴 PRIORITÉ HAUTE (P0 - Critique)
#### 1. Réorganisation de l'architecture Resources
- [ ] **AUDIT-001** : Analyser toutes les Resources existantes et leurs responsabilités
- [ ] **AUDIT-002** : Choisir une architecture unifiée (adapter/http recommandé)
- [ ] **AUDIT-003** : Migrer `application/rest/*` vers `adapter/http/`
- [ ] **AUDIT-004** : Migrer `presentation/rest/*` vers `adapter/http/`
- [ ] **AUDIT-005** : Décider du rôle de `presentation/controller/` (garder ou supprimer?)
- [ ] **AUDIT-006** : Mettre à jour tous les imports après migration
- [ ] **AUDIT-007** : Tester que tous les endpoints fonctionnent après migration
#### 2. Implémentation ENTREPRISE complète
- [ ] **ENTREPRISE-001** : Créer `EntrepriseProfileService.java`
- [ ] **ENTREPRISE-002** : Créer `EntrepriseProfileRepository.java` (si nécessaire)
- [ ] **ENTREPRISE-003** : Créer `EntrepriseResource.java` dans `adapter/http/`
- [ ] **ENTREPRISE-004** : Implémenter tous les endpoints CRUD
- [ ] **ENTREPRISE-005** : Créer `EntrepriseProfileDTO.java`
- [ ] **ENTREPRISE-006** : Créer `AvisEntrepriseResource.java`
- [ ] **ENTREPRISE-007** : Implémenter gestion des avis
- [ ] **ENTREPRISE-008** : Ajouter endpoints statistiques entreprise
#### 3. Implémentation ABONNEMENT complète
- [ ] **ABONNEMENT-001** : Créer entité `Abonnement.java`
- [ ] **ABONNEMENT-002** : Créer `AbonnementService.java`
- [ ] **ABONNEMENT-003** : Créer `AbonnementRepository.java`
- [ ] **ABONNEMENT-004** : Créer `AbonnementResource.java`
- [ ] **ABONNEMENT-005** : Implémenter tous les endpoints CRUD
- [ ] **ABONNEMENT-006** : Créer `AbonnementDTO.java`
- [ ] **ABONNEMENT-007** : Implémenter logique de renouvellement
- [ ] **ABONNEMENT-008** : Implémenter gestion plans tarifaires
### 🟡 PRIORITÉ MOYENNE (P1 - Important)
#### 4. Création DTO pour tous les concepts
- [ ] **DTO-001** : Créer `DevisCreateDTO.java`, `DevisResponseDTO.java`
- [ ] **DTO-002** : Créer `FactureCreateDTO.java`, `FactureResponseDTO.java`
- [ ] **DTO-003** : Créer `BudgetCreateDTO.java`, `BudgetResponseDTO.java`
- [ ] **DTO-004** : Créer `EmployeCreateDTO.java`, `EmployeResponseDTO.java`
- [ ] **DTO-005** : Créer `MaterielCreateDTO.java`, `MaterielResponseDTO.java`
- [ ] **DTO-006** : Créer `ChantierUpdateDTO.java`
- [ ] **DTO-007** : Créer DTOs pour Planning
- [ ] **DTO-008** : Créer DTOs pour Stock
- [ ] **DTO-009** : Créer DTOs pour BonCommande
- [ ] **DTO-010** : Créer DTOs pour toutes les entités majeures
#### 5. Création Mappers pour tous les DTO
- [ ] **MAPPER-001** : Créer `DevisMapper.java`
- [ ] **MAPPER-002** : Créer `FactureMapper.java`
- [ ] **MAPPER-003** : Créer `BudgetMapper.java`
- [ ] **MAPPER-004** : Créer `EmployeMapper.java`
- [ ] **MAPPER-005** : Créer `MaterielMapper.java`
- [ ] **MAPPER-006** : Créer `PlanningMapper.java`
- [ ] **MAPPER-007** : Créer mappers pour toutes les entités avec DTO
#### 6. Standardisation des endpoints
- [ ] **STD-001** : Vérifier que tous les endpoints retournent JSON
- [ ] **STD-002** : Standardiser format de réponse (wrapper avec `data`, `total`, etc.)
- [ ] **STD-003** : Ajouter pagination à tous les endpoints list
- [ ] **STD-004** : Standardiser messages d'erreur
- [ ] **STD-005** : Ajouter annotations OpenAPI complètes partout
- [ ] **STD-006** : Standardiser logs (GET /path, POST /path, etc.)
- [ ] **STD-007** : Ajouter `@Authenticated` ou `@RequirePermission` partout
### 🟢 PRIORITÉ BASSE (P2 - Améliorations)
#### 7. Complétion endpoints avancés
- [ ] **ADV-001** : Ajouter endpoints recherche avancée pour tous les concepts
- [ ] **ADV-002** : Ajouter endpoints statistiques pour tous les concepts
- [ ] **ADV-003** : Ajouter endpoints export/import CSV/Excel
- [ ] **ADV-004** : Ajouter endpoints notification push
- [ ] **ADV-005** : Ajouter endpoints génération PDF
#### 8. Documentation
- [ ] **DOC-001** : Compléter `API.md` avec tous les nouveaux endpoints
- [ ] **DOC-002** : Ajouter exemples d'utilisation pour chaque endpoint
- [ ] **DOC-003** : Documenter toutes les entités dans concepts/
- [ ] **DOC-004** : Mettre à jour README.md
#### 9. Tests
- [ ] **TEST-001** : Créer tests unitaires pour tous les services
- [ ] **TEST-002** : Créer tests d'intégration pour tous les endpoints
- [ ] **TEST-003** : Créer tests E2E pour workflows métier
- [ ] **TEST-004** : Ajouter tests performance
---
## 📊 RÉCAPITULATIF
### Concepts
-**Complets** : 20/22 (91%)
- ⚠️ **Partiels** : 1/22 (4.5%)
-**Manquants** : 1/22 (4.5%)
### Services
-**Existants** : 33
-**Manquants** : 2 (EntrepriseProfile, Abonnement)
### Resources
-**Existantes** : ~40
- ⚠️ **Problème organisation** : 4 emplacements différents
-**Manquantes** : 2 (EntrepriseProfile, Abonnement)
### DTO/Mappers
-**Existants** : 2 concepts complets (Chantier, Client)
- ⚠️ **Partiels** : 1 concept (Fournisseur)
-**Manquants** : ~18 concepts
---
## 🎯 PROCHAINES ÉTAPES RECOMMANDÉES
1. **Commencez par P0** : Réorganisation Resources + Entreprise + Abonnement
2. **Puis P1** : DTO et Mappers
3. **Ensuite P2** : Améliorations et documentation
**Estimation globale** : ~80-100 heures de développement