Migration complète vers PrimeFaces Freya - Corrections des incompatibilités et intégration de primefaces-freya-extension

This commit is contained in:
lionsdev
2025-12-27 00:18:31 +00:00
parent 5e272a8256
commit 5c996931a6
206 changed files with 36646 additions and 1593 deletions

148
test-keycloak-config.sh Normal file
View File

@@ -0,0 +1,148 @@
#!/bin/bash
# Script de test de la configuration Keycloak pour lions-user-manager
# Usage: ./test-keycloak-config.sh
set -e
KEYCLOAK_URL="http://localhost:8180"
REALM="lions-user-manager"
CLIENT_ID="lions-user-manager-client"
CLIENT_SECRET="NTuaQpk5E6qiMqAWTFrCOcIkOABzZzKO"
USERNAME="testadmin"
PASSWORD="admin123"
BACKEND_URL="http://localhost:8081"
echo "=========================================="
echo "Test de configuration Keycloak"
echo "=========================================="
echo ""
# Test 1: Vérifier que Keycloak est accessible
echo "[1/4] Vérification de l'accès à Keycloak..."
if curl -s -f "$KEYCLOAK_URL" > /dev/null 2>&1; then
echo "✅ Keycloak est accessible sur $KEYCLOAK_URL"
else
echo "❌ Keycloak n'est pas accessible sur $KEYCLOAK_URL"
echo " Assurez-vous que Keycloak est démarré."
exit 1
fi
echo ""
# Test 2: Obtenir un token
echo "[2/4] Obtention d'un token d'accès..."
TOKEN_RESPONSE=$(curl -s -X POST \
"$KEYCLOAK_URL/realms/$REALM/protocol/openid-connect/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "client_id=$CLIENT_ID" \
-d "client_secret=$CLIENT_SECRET" \
-d "grant_type=password" \
-d "username=$USERNAME" \
-d "password=$PASSWORD" \
-d "scope=openid profile email roles")
if echo "$TOKEN_RESPONSE" | grep -q "access_token"; then
ACCESS_TOKEN=$(echo "$TOKEN_RESPONSE" | grep -o '"access_token":"[^"]*' | cut -d'"' -f4)
echo "✅ Token obtenu avec succès"
echo " Token (premiers 50 caractères): ${ACCESS_TOKEN:0:50}..."
else
echo "❌ Impossible d'obtenir un token"
echo " Réponse de Keycloak:"
echo "$TOKEN_RESPONSE" | python3 -m json.tool 2>/dev/null || echo "$TOKEN_RESPONSE"
echo ""
echo "Vérifiez que:"
echo " - Le realm '$REALM' existe"
echo " - Le client '$CLIENT_ID' existe avec le bon secret"
echo " - L'utilisateur '$USERNAME' existe avec le mot de passe '$PASSWORD'"
exit 1
fi
echo ""
# Test 3: Vérifier le contenu du token
echo "[3/4] Vérification du contenu du token..."
TOKEN_PAYLOAD=$(echo "$ACCESS_TOKEN" | cut -d'.' -f2)
# Ajouter le padding si nécessaire pour base64
TOKEN_PAYLOAD_PADDED=$(echo "$TOKEN_PAYLOAD" | awk '{while(length($0) % 4 != 0) $0 = $0 "="; print}')
TOKEN_DECODED=$(echo "$TOKEN_PAYLOAD_PADDED" | base64 -d 2>/dev/null || echo "{}")
echo "$TOKEN_DECODED" | python3 -m json.tool > /tmp/token_decoded.json 2>/dev/null || echo "$TOKEN_DECODED" > /tmp/token_decoded.json
if grep -q "realm_access" /tmp/token_decoded.json; then
echo "✅ Le token contient les rôles (realm_access)"
ROLES=$(cat /tmp/token_decoded.json | grep -A 10 "realm_access" | grep -A 5 "roles" || echo "[]")
echo " Rôles trouvés: $ROLES"
else
echo "❌ Le token ne contient pas realm_access.roles"
echo " Vérifiez la configuration du client scope 'roles' dans Keycloak"
fi
if grep -q "\"admin\"" /tmp/token_decoded.json || grep -q "\"user_manager\"" /tmp/token_decoded.json; then
echo "✅ L'utilisateur a le rôle 'admin' ou 'user_manager'"
else
echo "⚠️ L'utilisateur n'a pas le rôle 'admin' ou 'user_manager'"
echo " L'endpoint /api/users/search nécessite un de ces rôles"
echo " Assignez le rôle 'admin' ou 'user_manager' à l'utilisateur '$USERNAME'"
fi
echo ""
# Test 4: Tester l'API backend
echo "[4/4] Test de l'endpoint /api/users/search..."
API_RESPONSE=$(curl -s -w "\nHTTP_CODE:%{http_code}" -X POST \
"$BACKEND_URL/api/users/search" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '{
"realmName": "'"$REALM"'",
"page": 0,
"pageSize": 20
}' 2>/dev/null)
HTTP_CODE=$(echo "$API_RESPONSE" | grep "HTTP_CODE:" | cut -d':' -f2)
RESPONSE_BODY=$(echo "$API_RESPONSE" | sed '/HTTP_CODE:/d')
if [ "$HTTP_CODE" = "200" ]; then
echo "✅ Endpoint /api/users/search accessible (HTTP 200)"
echo " Nombre d'utilisateurs trouvés: $(echo "$RESPONSE_BODY" | grep -o '"totalCount":[0-9]*' | cut -d':' -f2 || echo "?")"
elif [ "$HTTP_CODE" = "000" ] || [ -z "$HTTP_CODE" ]; then
echo "❌ Le backend n'est pas accessible sur $BACKEND_URL"
echo " Assurez-vous que lions-user-manager-server est démarré (mvn quarkus:dev)"
elif [ "$HTTP_CODE" = "401" ]; then
echo "❌ Erreur 401 Unauthorized"
echo " Le token n'est pas accepté par le backend"
echo " Vérifiez que le serveur utilise le même realm dans application.properties"
elif [ "$HTTP_CODE" = "403" ]; then
echo "❌ Erreur 403 Forbidden"
echo " L'utilisateur n'a pas les permissions nécessaires"
echo " Assignez le rôle 'admin' ou 'user_manager' à l'utilisateur"
elif [ "$HTTP_CODE" = "405" ]; then
echo "❌ Erreur 405 Method Not Allowed"
echo " C'est l'erreur que vous rencontriez !"
echo " Vérifiez que le serveur backend est bien configuré avec le realm '$REALM'"
else
echo "⚠️ Réponse HTTP $HTTP_CODE"
echo " Réponse: $RESPONSE_BODY"
fi
echo ""
# Résumé
echo "=========================================="
echo "Résumé du test"
echo "=========================================="
echo ""
if [ "$HTTP_CODE" = "200" ]; then
echo "🎉 Configuration correcte ! Tout fonctionne."
echo ""
echo "Vous pouvez maintenant:"
echo " 1. Démarrer le client: cd lions-user-manager-client-quarkus-primefaces-freya && mvn quarkus:dev"
echo " 2. Accéder à: http://localhost:8082"
echo " 3. Se connecter avec: $USERNAME / $PASSWORD"
echo " 4. Naviguer vers: /pages/user-manager/users/list.xhtml"
else
echo "❌ La configuration nécessite des ajustements."
echo ""
echo "Consultez le fichier KEYCLOAK_DEV_SETUP.md pour les instructions complètes."
fi
echo ""
# Cleanup
rm -f /tmp/token_decoded.json