diff --git a/README_PORTS.md b/README_PORTS.md new file mode 100644 index 0000000..76f4c09 --- /dev/null +++ b/README_PORTS.md @@ -0,0 +1,212 @@ +# Configuration des Ports - Lions User Manager + +## ✅ Problème résolu : Conflit de ports + +**Problème initial** : Les deux applications (frontend et backend) étaient configurées sur le **même port 8081**, ce qui empêchait le backend de démarrer. + +**Solution** : Ports correctement séparés. + +## 🌐 Configuration des Ports + +### Frontend (Interface Web JSF/PrimeFaces) +- **Port** : `8080` +- **URL** : http://localhost:8080 +- **Type** : Application web avec OIDC activé +- **Fichier** : `lions-user-manager-client-quarkus-primefaces-freya/src/main/resources/application.properties` + +```properties +quarkus.http.port=8080 +``` + +### Backend (API REST) +- **Port** : `8081` +- **URL** : http://localhost:8081 +- **Type** : API REST (pas de pages web) +- **Fichier** : `lions-user-manager-server-impl-quarkus/src/main/resources/application.properties` + +```properties +quarkus.http.port=8081 +``` + +### Keycloak (Serveur d'authentification) +- **Port** : `8180` +- **URL** : http://localhost:8180 +- **Admin Console** : http://localhost:8180/admin +- **Credentials** : admin / admin + +## 🚀 Démarrage des applications + +### 1. Démarrer Keycloak (si nécessaire) +```bash +# Vérifier si Keycloak tourne +curl http://localhost:8180/health + +# Si Keycloak ne tourne pas, le démarrer (exemple avec Docker) +docker run -p 8180:8080 \ + -e KEYCLOAK_ADMIN=admin \ + -e KEYCLOAK_ADMIN_PASSWORD=admin \ + quay.io/keycloak/keycloak:latest start-dev +``` + +### 2. Démarrer le Backend (port 8081) +```bash +cd lions-user-manager-server-impl-quarkus +mvn clean quarkus:dev +``` + +**Vérification** : +```bash +# Swagger UI +curl http://localhost:8081/q/swagger-ui + +# Dev UI +curl http://localhost:8081/q/dev + +# Health Check +curl http://localhost:8081/q/health +``` + +### 3. Démarrer le Frontend (port 8080) +```bash +cd lions-user-manager-client-quarkus-primefaces-freya +mvn clean quarkus:dev +``` + +**Vérification** : +```bash +# Page d'accueil +curl http://localhost:8080 + +# Ou ouvrir dans le navigateur +http://localhost:8080 +``` + +## 📋 Architecture + +``` +┌─────────────────────────────────────────────┐ +│ Navigateur Web │ +└────────────┬────────────────────────────────┘ + │ + │ 1. Accès à http://localhost:8080 + │ + ▼ +┌─────────────────────────────────────────────┐ +│ FRONTEND (Port 8080) │ +│ - Pages web JSF/PrimeFaces │ +│ - OIDC activé │ +│ - Redirige vers Keycloak pour login │ +└────────────┬────────────────────────────────┘ + │ + │ 2. Appelle l'API backend + │ http://localhost:8081/api/* + │ + ▼ +┌─────────────────────────────────────────────┐ +│ BACKEND (Port 8081) │ +│ - API REST │ +│ - OIDC désactivé (utilise Admin API) │ +│ - Endpoints: /api/users, /api/roles, etc. │ +└────────────┬────────────────────────────────┘ + │ + │ 3. Gère les utilisateurs via Admin API + │ + ▼ +┌─────────────────────────────────────────────┐ +│ KEYCLOAK (Port 8180) │ +│ - Realm: lions-user-manager │ +│ - Client: lions-user-manager-client │ +│ - Admin API │ +└─────────────────────────────────────────────┘ +``` + +## 🔧 Flux d'authentification + +1. **Utilisateur accède au frontend** : http://localhost:8080 +2. **Frontend redirige vers Keycloak** : http://localhost:8180/realms/lions-user-manager +3. **Utilisateur se connecte** : testuser / test123 +4. **Keycloak retourne un token** +5. **Frontend est authentifié** et peut appeler le backend +6. **Backend utilise Admin API** pour gérer Keycloak (admin/admin) + +## ❌ Ce qui NE fonctionnera PAS + +### ❌ http://localhost:8081 (racine du backend) +**Erreur** : Forbidden ou 404 + +**Raison** : Le backend est une API REST, il n'a pas de page d'accueil HTML. + +**Solution** : Utilisez plutôt : +- http://localhost:8081/q/swagger-ui (interface graphique API) +- http://localhost:8081/q/dev (console dev Quarkus) +- http://localhost:8081/api/users?realm=lions-user-manager (endpoint API) + +### ❌ http://localhost:8080/api/users +**Erreur** : 404 + +**Raison** : Les API sont sur le backend (port 8081), pas le frontend (8080). + +**Solution** : http://localhost:8081/api/users?realm=lions-user-manager + +## ✅ URLs correctes + +### Frontend (8080) +- **Accueil** : http://localhost:8080 +- **Login** : Automatiquement redirigé vers Keycloak +- **Pages protégées** : http://localhost:8080/pages/user-manager/users/list.xhtml + +### Backend (8081) +- **Swagger UI** : http://localhost:8081/q/swagger-ui +- **Dev UI** : http://localhost:8081/q/dev +- **Health Check** : http://localhost:8081/q/health +- **API Users** : http://localhost:8081/api/users?realm=lions-user-manager +- **API Roles** : http://localhost:8081/api/roles/realm?realm=lions-user-manager + +### Keycloak (8180) +- **Admin Console** : http://localhost:8180/admin +- **Account Console** : http://localhost:8180/realms/lions-user-manager/account + +## 🔍 Diagnostic + +### Le frontend ne démarre pas +```bash +# Vérifier qu'aucun processus n'utilise le port 8080 +netstat -ano | findstr :8080 + +# Logs du frontend +cd lions-user-manager-client-quarkus-primefaces-freya +mvn quarkus:dev +``` + +### Le backend ne démarre pas +```bash +# Vérifier qu'aucun processus n'utilise le port 8081 +netstat -ano | findstr :8081 + +# Logs du backend +cd lions-user-manager-server-impl-quarkus +mvn quarkus:dev +``` + +### Keycloak n'est pas accessible +```bash +# Vérifier le statut +curl http://localhost:8180/health + +# Redémarrer si nécessaire +``` + +## 📝 Credentials + +- **Keycloak Admin** : admin / admin +- **Utilisateur de test** : testuser / test123 +- **Realm** : lions-user-manager +- **Client ID** : lions-user-manager-client +- **Client Secret** : client-secret-lions-2025 + +--- + +**Important** : Toujours démarrer dans cet ordre : +1. Keycloak (8180) +2. Backend (8081) +3. Frontend (8080)