diff --git a/.gitignore b/.gitignore index b09a99b..d44274a 100644 --- a/.gitignore +++ b/.gitignore @@ -37,5 +37,8 @@ frontend/.flutter-plugins frontend/.flutter-plugins-dependencies frontend/build/ +# Claude Code (contient des tokens et commandes sensibles) +.claude/ + # Docs sensibles memoire de fin d'etude.docx diff --git a/Debut de creation.md b/Fichiers_de_preparation/Debut de creation.md similarity index 100% rename from Debut de creation.md rename to Fichiers_de_preparation/Debut de creation.md diff --git a/Plan d'Action pour le Projet E.md b/Fichiers_de_preparation/Plan d'Action pour le Projet E.md similarity index 100% rename from Plan d'Action pour le Projet E.md rename to Fichiers_de_preparation/Plan d'Action pour le Projet E.md diff --git a/Rayhan-ERP.md b/Fichiers_de_preparation/Rayhan-ERP.md similarity index 100% rename from Rayhan-ERP.md rename to Fichiers_de_preparation/Rayhan-ERP.md diff --git a/Resumé et besoin.md b/Fichiers_de_preparation/Resumé et besoin.md similarity index 100% rename from Resumé et besoin.md rename to Fichiers_de_preparation/Resumé et besoin.md diff --git a/Résumé Détaillé du Projet ERP — SUARL Rayhan.txt b/Fichiers_de_preparation/Résumé Détaillé du Projet ERP — SUARL Rayhan.txt similarity index 100% rename from Résumé Détaillé du Projet ERP — SUARL Rayhan.txt rename to Fichiers_de_preparation/Résumé Détaillé du Projet ERP — SUARL Rayhan.txt diff --git a/Livrables/SUIVI-PROJET.md b/Livrables/SUIVI-PROJET.md index 666ffdf..9e3accc 100644 --- a/Livrables/SUIVI-PROJET.md +++ b/Livrables/SUIVI-PROJET.md @@ -14,7 +14,7 @@ | 3 | Backend Spring Boot API | ✅ Déployé & Fonctionnel | | 4 | Frontend Flutter | ⏳ À faire | | 5 | Tests & Validation | 🔄 En cours | -| 6 | Déploiement Production | ✅ Docker sur 192.168.100.33:8090 | +| 6 | Déploiement Production | ✅ Docker — https://rayhan-erp.bolbol.tn | | 7 | Rapport de PFE | 🔄 En cours | --- @@ -88,11 +88,9 @@ ## Infrastructure Serveur -- **Serveur local** : 192.168.100.33 -- **SSH** : port 22222, user Best0f -- **Portainer** : http://192.168.100.33:9000/ - **Gitea** : https://gitea.bolbol.tn -- **API REST** : http://192.168.100.33:8090 ✅ En ligne +- **API REST (production)** : https://rayhan-erp.bolbol.tn ✅ En ligne +- **API REST (local dev)** : http://localhost:8090 - **Conteneurs Docker** : `rayhan-mysql` + `rayhan-backend` --- diff --git a/Livrables/docs/Guide-Installation-Windows.md b/Livrables/docs/Guide-Installation-Windows.md index 4da040e..506ab25 100644 --- a/Livrables/docs/Guide-Installation-Windows.md +++ b/Livrables/docs/Guide-Installation-Windows.md @@ -179,7 +179,7 @@ Password : rayhan_erp_2024 > MySQL Workbench : https://dev.mysql.com/downloads/workbench/ -**Note :** Sur le serveur de production (192.168.100.33), le port MySQL n'est pas exposé à l'extérieur par mesure de sécurité. +**Note :** Sur le serveur de production (localhost), le port MySQL n'est pas exposé à l'extérieur par mesure de sécurité. --- diff --git a/Livrables/docs/Guide-Tests-Postman.md b/Livrables/docs/Guide-Tests-Postman.md index 13c7967..466cbd0 100644 --- a/Livrables/docs/Guide-Tests-Postman.md +++ b/Livrables/docs/Guide-Tests-Postman.md @@ -3,12 +3,12 @@ ## Configuration de Base -**URL de base** : `http://192.168.100.33:8090` +**URL de base** : `https://rayhan-erp.bolbol.tn` ### 1. Configurer une Variable d'Environnement Postman Dans Postman, créer un environnement "Rayhan ERP" avec : -- `baseUrl` = `http://192.168.100.33:8090` +- `baseUrl` = `https://rayhan-erp.bolbol.tn` - `token` = (sera rempli automatiquement) --- diff --git a/Livrables/rapport-projet.md b/Livrables/rapport-projet.md index 36fa2b7..b9b9b69 100644 --- a/Livrables/rapport-projet.md +++ b/Livrables/rapport-projet.md @@ -204,7 +204,7 @@ La base de données `rayhan_erp_db` contient les tables suivantes : ## 4.1 Infrastructure -L'application est déployée sur un serveur NAS Synology (192.168.100.33) via Docker Compose. Deux conteneurs sont en production : +L'application est déployée via Docker Compose, accessible publiquement derrière un reverse proxy HTTPS. Deux conteneurs sont en production : - **rayhan-mysql** — MySQL 8, base de données `rayhan_erp_db` - **rayhan-backend** — Spring Boot, accessible sur le port **8090** @@ -254,8 +254,8 @@ ENTRYPOINT ["java", "-jar", "app.jar"] | Service | URL | |---------|-----| -| API REST | http://192.168.100.33:8090 | -| Documentation Swagger UI | http://192.168.100.33:8090/swagger-ui/index.html | +| API REST | https://rayhan-erp.bolbol.tn | +| Documentation Swagger UI | https://rayhan-erp.bolbol.tn/swagger-ui/index.html | | Dépôt source (Gitea) | https://gitea.bolbol.tn/bolbol/rayhan-erp | --- @@ -272,7 +272,7 @@ L'API intègre **Swagger UI** (SpringDoc OpenAPI 2.5.0), accessible depuis n'imp **Procédure de test :** -1. Ouvrir http://192.168.100.33:8090/swagger-ui/index.html +1. Ouvrir https://rayhan-erp.bolbol.tn/swagger-ui/index.html 2. Exécuter `POST /api/auth/signin` avec `{"username":"admin","password":"Rayhan2024!"}` 3. Copier le token de la réponse 4. Cliquer sur **Authorize 🔒** → coller le token → Authorize diff --git a/backend/src/main/java/com/rayhan/erp/config/WebSecurityConfig.java b/backend/src/main/java/com/rayhan/erp/config/WebSecurityConfig.java index 694d1af..ca0f20a 100644 --- a/backend/src/main/java/com/rayhan/erp/config/WebSecurityConfig.java +++ b/backend/src/main/java/com/rayhan/erp/config/WebSecurityConfig.java @@ -17,6 +17,11 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.CorsConfigurationSource; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; + +import java.util.List; @Configuration @EnableMethodSecurity @@ -51,9 +56,26 @@ public class WebSecurityConfig { return new BCryptPasswordEncoder(); } + @Bean + public CorsConfigurationSource corsConfigurationSource() { + CorsConfiguration config = new CorsConfiguration(); + config.setAllowedOriginPatterns(List.of( + "https://rayhan-erp.bolbol.tn", + "http://localhost:*", + "http://127.0.0.1:*" + )); + config.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "OPTIONS")); + config.setAllowedHeaders(List.of("*")); + config.setAllowCredentials(true); + UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); + source.registerCorsConfiguration("/**", config); + return source; + } + @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { http + .cors(cors -> cors.configurationSource(corsConfigurationSource())) .csrf(AbstractHttpConfigurer::disable) .exceptionHandling(exception -> exception.authenticationEntryPoint(unauthorizedHandler)) .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) diff --git a/backend/src/main/java/com/rayhan/erp/controller/ArticleController.java b/backend/src/main/java/com/rayhan/erp/controller/ArticleController.java index 2e67d75..5605390 100644 --- a/backend/src/main/java/com/rayhan/erp/controller/ArticleController.java +++ b/backend/src/main/java/com/rayhan/erp/controller/ArticleController.java @@ -10,7 +10,6 @@ import org.springframework.web.bind.annotation.*; import java.util.List; -@CrossOrigin(origins = "*", maxAge = 3600) @RestController @RequestMapping("/api/articles") public class ArticleController { diff --git a/backend/src/main/java/com/rayhan/erp/controller/AuthController.java b/backend/src/main/java/com/rayhan/erp/controller/AuthController.java index 1737949..074498c 100644 --- a/backend/src/main/java/com/rayhan/erp/controller/AuthController.java +++ b/backend/src/main/java/com/rayhan/erp/controller/AuthController.java @@ -26,7 +26,6 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; -@CrossOrigin(origins = "*", maxAge = 3600) @RestController @RequestMapping("/api/auth") public class AuthController { diff --git a/backend/src/main/java/com/rayhan/erp/controller/ClientController.java b/backend/src/main/java/com/rayhan/erp/controller/ClientController.java index 2c1b538..e224a63 100644 --- a/backend/src/main/java/com/rayhan/erp/controller/ClientController.java +++ b/backend/src/main/java/com/rayhan/erp/controller/ClientController.java @@ -10,7 +10,6 @@ import org.springframework.web.bind.annotation.*; import java.util.List; -@CrossOrigin(origins = "*", maxAge = 3600) @RestController @RequestMapping("/api/clients") public class ClientController { diff --git a/backend/src/main/java/com/rayhan/erp/controller/DashboardController.java b/backend/src/main/java/com/rayhan/erp/controller/DashboardController.java index 604f37d..8c62bf3 100644 --- a/backend/src/main/java/com/rayhan/erp/controller/DashboardController.java +++ b/backend/src/main/java/com/rayhan/erp/controller/DashboardController.java @@ -15,7 +15,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -@CrossOrigin(origins = "*", maxAge = 3600) @RestController @RequestMapping("/api/dashboard") public class DashboardController { diff --git a/backend/src/main/java/com/rayhan/erp/controller/FournisseurController.java b/backend/src/main/java/com/rayhan/erp/controller/FournisseurController.java index 296e8b7..31e3cd7 100644 --- a/backend/src/main/java/com/rayhan/erp/controller/FournisseurController.java +++ b/backend/src/main/java/com/rayhan/erp/controller/FournisseurController.java @@ -10,7 +10,6 @@ import org.springframework.web.bind.annotation.*; import java.util.List; -@CrossOrigin(origins = "*", maxAge = 3600) @RestController @RequestMapping("/api/fournisseurs") public class FournisseurController { diff --git a/backend/src/main/java/com/rayhan/erp/controller/ProductionOrderController.java b/backend/src/main/java/com/rayhan/erp/controller/ProductionOrderController.java index e48d9c9..2ab8351 100644 --- a/backend/src/main/java/com/rayhan/erp/controller/ProductionOrderController.java +++ b/backend/src/main/java/com/rayhan/erp/controller/ProductionOrderController.java @@ -18,7 +18,6 @@ import java.time.LocalDate; import java.util.List; import java.util.Map; -@CrossOrigin(origins = "*", maxAge = 3600) @RestController @RequestMapping("/api/production") public class ProductionOrderController { diff --git a/backend/src/main/java/com/rayhan/erp/controller/PurchaseOrderController.java b/backend/src/main/java/com/rayhan/erp/controller/PurchaseOrderController.java index 5310a5e..3f062b5 100644 --- a/backend/src/main/java/com/rayhan/erp/controller/PurchaseOrderController.java +++ b/backend/src/main/java/com/rayhan/erp/controller/PurchaseOrderController.java @@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.*; import java.util.List; -@CrossOrigin(origins = "*", maxAge = 3600) @RestController @RequestMapping("/api/purchase-orders") public class PurchaseOrderController { diff --git a/backend/src/main/java/com/rayhan/erp/controller/SalesOrderController.java b/backend/src/main/java/com/rayhan/erp/controller/SalesOrderController.java index 312132a..29a661c 100644 --- a/backend/src/main/java/com/rayhan/erp/controller/SalesOrderController.java +++ b/backend/src/main/java/com/rayhan/erp/controller/SalesOrderController.java @@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.*; import java.util.List; -@CrossOrigin(origins = "*", maxAge = 3600) @RestController @RequestMapping("/api/sales-orders") public class SalesOrderController { diff --git a/backend/src/main/java/com/rayhan/erp/controller/StockController.java b/backend/src/main/java/com/rayhan/erp/controller/StockController.java index bc28313..fdd1754 100644 --- a/backend/src/main/java/com/rayhan/erp/controller/StockController.java +++ b/backend/src/main/java/com/rayhan/erp/controller/StockController.java @@ -17,7 +17,6 @@ import java.math.BigDecimal; import java.util.List; import java.util.Map; -@CrossOrigin(origins = "*", maxAge = 3600) @RestController @RequestMapping("/api/stock") public class StockController { diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index a84128e..4145560 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -6,6 +6,11 @@ # Serveur server.port=8080 +# Reverse proxy HTTPS (Nginx/Traefik devant le conteneur) +server.forward-headers-strategy=framework +server.tomcat.remoteip.remote-ip-header=x-forwarded-for +server.tomcat.remoteip.protocol-header=x-forwarded-proto + # Base de données MySQL spring.datasource.url=jdbc:mysql://localhost:3306/rayhan_erp_db?createDatabaseIfNotExist=true&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Africa/Tunis spring.datasource.username=root