diff --git a/TEST_BACKEND.md b/TEST_BACKEND.md new file mode 100644 index 0000000..5a6630f --- /dev/null +++ b/TEST_BACKEND.md @@ -0,0 +1,106 @@ +# Test du Backend - Lions User Manager + +## ⚠️ Important : Le port 8081 ne sert PAS de pages web ! + +Le message "Forbidden" sur `http://localhost:8081/` est **NORMAL**. + +Le backend est une **API REST** uniquement, il n'a pas de page d'accueil HTML. + +## ✅ URLs à tester à la place : + +### 1. Swagger UI (Interface de documentation API) +``` +http://localhost:8081/q/swagger-ui +``` +C'est l'interface graphique pour tester toutes les API. + +### 2. Health Check +``` +http://localhost:8081/q/health +``` +Vérifie que l'application tourne correctement. + +### 3. Metrics +``` +http://localhost:8081/q/metrics +``` +Statistiques de l'application. + +### 4. API Users (endpoint principal) +```bash +# Lister les utilisateurs du realm lions-user-manager +curl "http://localhost:8081/api/users?realm=lions-user-manager" + +# Ou dans votre navigateur : +http://localhost:8081/api/users?realm=lions-user-manager +``` + +### 5. Dev UI (Console de développement Quarkus) +``` +http://localhost:8081/q/dev +``` + +## 🔧 Test complet avec curl + +```bash +# 1. Health check +curl http://localhost:8081/q/health + +# 2. Lister les utilisateurs +curl "http://localhost:8081/api/users?realm=lions-user-manager" + +# 3. Lister les rôles +curl "http://localhost:8081/api/roles/realm?realm=lions-user-manager" + +# 4. Health check Keycloak +curl http://localhost:8081/api/health/keycloak +``` + +## 🌐 Pour l'interface WEB, utilisez le frontend : + +L'interface web JSF/PrimeFaces est sur le **port 8080** : +``` +http://localhost:8080 +``` + +C'est là que vous verrez les pages XHTML et pourrez vous connecter avec `testuser/test123`. + +## 📊 Architecture + +``` +┌─────────────────────┐ +│ Frontend (8080) │ ← Pages web XHTML/PrimeFaces +│ Interface utilisateur +└──────────┬──────────┘ + │ + │ Appelle les API + │ + ▼ +┌─────────────────────┐ +│ Backend (8081) │ ← API REST uniquement (pas de pages web) +│ Endpoints REST │ C'est pour ça que / retourne Forbidden +└─────────────────────┘ +``` + +## ❓ Pourquoi "Forbidden" ? + +Le backend Quarkus est configuré avec : +```properties +quarkus.oidc.enabled=false +quarkus.security.jaxrs.deny-unannotated-endpoints=false +``` + +Mais il n'y a **aucun endpoint** défini pour `/` (la racine). + +Les seuls endpoints disponibles sont : +- `/api/*` - API REST +- `/q/*` - Endpoints Quarkus (dev UI, health, metrics, swagger) + +## ✅ Solution + +**Utilisez Swagger UI** pour tester l'API : +``` +http://localhost:8081/q/swagger-ui +``` + +Ou testez directement les endpoints API avec curl ou votre navigateur. diff --git a/get-client-secret.sh b/get-client-secret.sh new file mode 100644 index 0000000..a1706d8 --- /dev/null +++ b/get-client-secret.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +# Script pour récupérer le secret du client Keycloak + +KEYCLOAK_URL="http://localhost:8180" +REALM="lions-user-manager" + +# 1. Obtenir le token admin +TOKEN=$(curl -s -X POST "${KEYCLOAK_URL}/realms/master/protocol/openid-connect/token" \ + -H "Content-Type: application/x-www-form-urlencoded" \ + -d "username=admin" \ + -d "password=admin" \ + -d "grant_type=password" \ + -d "client_id=admin-cli" | grep -o '"access_token":"[^"]*' | cut -d'"' -f4) + +if [ -z "$TOKEN" ]; then + echo "Erreur: Impossible d'obtenir le token" + exit 1 +fi + +# 2. Récupérer tous les clients +CLIENTS=$(curl -s -X GET "${KEYCLOAK_URL}/admin/realms/${REALM}/clients" \ + -H "Authorization: Bearer ${TOKEN}") + +# 3. Extraire l'ID du client +CLIENT_ID=$(echo "$CLIENTS" | grep -B 5 '"clientId":"lions-user-manager-client"' | grep '"id"' | head -1 | grep -o '"id":"[^"]*' | cut -d'"' -f4) + +if [ -z "$CLIENT_ID" ]; then + echo "Erreur: Client non trouvé" + exit 1 +fi + +echo "Client ID interne: $CLIENT_ID" + +# 4. Récupérer le secret du client +SECRET=$(curl -s -X GET "${KEYCLOAK_URL}/admin/realms/${REALM}/clients/${CLIENT_ID}/client-secret" \ + -H "Authorization: Bearer ${TOKEN}" | grep -o '"value":"[^"]*' | cut -d'"' -f4) + +if [ -z "$SECRET" ]; then + echo "Erreur: Secret non trouvé" + exit 1 +fi + +echo "" +echo "=== Secret du client lions-user-manager-client ===" +echo "Secret: $SECRET" +echo "" +echo "Mettre à jour dans application-dev.properties:" +echo "quarkus.oidc.credentials.secret=$SECRET" diff --git a/lions-user-manager-client-quarkus-primefaces-freya/src/main/resources/application.properties b/lions-user-manager-client-quarkus-primefaces-freya/src/main/resources/application.properties index 2a30c95..54767bb 100644 --- a/lions-user-manager-client-quarkus-primefaces-freya/src/main/resources/application.properties +++ b/lions-user-manager-client-quarkus-primefaces-freya/src/main/resources/application.properties @@ -3,7 +3,7 @@ quarkus.application.name=lions-user-manager-client quarkus.application.version=1.0.0 # Configuration HTTP -quarkus.http.port=8081 +quarkus.http.port=8080 quarkus.http.host=0.0.0.0 quarkus.http.root-path=/ quarkus.http.so-reuse-port=true @@ -45,7 +45,7 @@ primefaces.AUTO_UPDATE=false primefaces.CACHE_PROVIDER=org.primefaces.cache.DefaultCacheProvider # Configuration Backend Lions User Manager -lions.user.manager.backend.url=${LIONS_USER_MANAGER_BACKEND_URL:http://localhost:8080} +lions.user.manager.backend.url=${LIONS_USER_MANAGER_BACKEND_URL:http://localhost:8081} # Configuration REST Client quarkus.rest-client."lions-user-manager-api".url=${lions.user.manager.backend.url} @@ -82,7 +82,7 @@ quarkus.http.auth.permission.authenticated.policy=authenticated # CORS (si nécessaire pour développement) quarkus.http.cors=true -quarkus.http.cors.origins=${CORS_ORIGINS:http://localhost:8081,http://localhost:8086} +quarkus.http.cors.origins=${CORS_ORIGINS:http://localhost:8080,http://localhost:8081} quarkus.http.cors.methods=GET,POST,PUT,DELETE,OPTIONS quarkus.http.cors.headers=Accept,Authorization,Content-Type,X-Requested-With diff --git a/test-auth.sh b/test-auth.sh new file mode 100644 index 0000000..7408d23 --- /dev/null +++ b/test-auth.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +echo "Test d'authentification avec le client lions-user-manager-client" +echo "" + +curl -X POST "http://localhost:8180/realms/lions-user-manager/protocol/openid-connect/token" \ + -H "Content-Type: application/x-www-form-urlencoded" \ + -d "client_id=lions-user-manager-client" \ + -d "client_secret=client-secret-lions-2025" \ + -d "username=testuser" \ + -d "password=test123" \ + -d "grant_type=password" + +echo ""