feat(mobile): Implement Keycloak WebView authentication with HTTP callback

- Replace flutter_appauth with custom WebView implementation to resolve deep link issues
- Add KeycloakWebViewAuthService with integrated WebView for seamless authentication
- Configure Android manifest for HTTP cleartext traffic support
- Add network security config for development environment (192.168.1.11)
- Update Keycloak client to use HTTP callback endpoint (http://192.168.1.11:8080/auth/callback)
- Remove obsolete keycloak_auth_service.dart and temporary scripts
- Clean up dependencies and regenerate injection configuration
- Tested successfully on multiple Android devices (Xiaomi 2201116TG, SM A725F)

BREAKING CHANGE: Authentication flow now uses WebView instead of external browser
- Users will see Keycloak login page within the app instead of browser redirect
- Resolves ERR_CLEARTEXT_NOT_PERMITTED and deep link state management issues
- Maintains full OIDC compliance with PKCE flow and secure token storage

Technical improvements:
- WebView with custom navigation delegate for callback handling
- Automatic token extraction and user info parsing from JWT
- Proper error handling and user feedback
- Consistent authentication state management across app lifecycle
This commit is contained in:
DahoudG
2025-09-15 01:44:16 +00:00
parent 73459b3092
commit f89f6167cc
290 changed files with 34563 additions and 3528 deletions

View File

@@ -0,0 +1,49 @@
# Script avec URIs valides (tirets au lieu d'underscores)
$KeycloakUrl = "http://192.168.1.11:8180"
$Realm = "unionflow"
$ClientId = "unionflow-mobile"
$ClientUuid = "67b09521-3c8d-4ab1-9d13-80af9240c64d"
Write-Host "=== CORRECTION AVEC URIs VALIDES ===" -ForegroundColor Cyan
try {
# Obtenir token admin
$tokenResponse = Invoke-RestMethod -Uri "$KeycloakUrl/realms/master/protocol/openid-connect/token" -Method Post -ContentType "application/x-www-form-urlencoded" -Body "username=admin&password=admin&grant_type=password&client_id=admin-cli"
$accessToken = $tokenResponse.access_token
Write-Host "✅ Token obtenu" -ForegroundColor Green
# Récupérer le client actuel
$headers = @{ "Authorization" = "Bearer $accessToken" }
$client = Invoke-RestMethod -Uri "$KeycloakUrl/admin/realms/$Realm/clients/$ClientUuid" -Method Get -Headers $headers
Write-Host "📋 Client actuel récupéré" -ForegroundColor Yellow
# Mettre à jour seulement les redirect URIs
$client.redirectUris = @(
"dev.lions.unionflow-mobile://callback",
"dev.lions.unionflow-mobile://login-callback",
"dev.lions.unionflow-mobile://oauth/callback"
)
$client.webOrigins = @("+")
$clientJson = $client | ConvertTo-Json -Depth 10
# Mettre à jour le client
Invoke-RestMethod -Uri "$KeycloakUrl/admin/realms/$Realm/clients/$ClientUuid" -Method Put -Headers $headers -Body $clientJson -ContentType "application/json"
Write-Host "✅ Client mis à jour avec succès !" -ForegroundColor Green
Write-Host ""
Write-Host "Nouvelles redirect URIs (VALIDES):" -ForegroundColor Yellow
Write-Host " - dev.lions.unionflow-mobile://callback" -ForegroundColor Gray
Write-Host " - dev.lions.unionflow-mobile://login-callback" -ForegroundColor Gray
Write-Host " - dev.lions.unionflow-mobile://oauth/callback" -ForegroundColor Gray
} catch {
Write-Host "❌ Erreur: $($_.Exception.Message)" -ForegroundColor Red
if ($_.Exception.Response) {
$reader = New-Object System.IO.StreamReader($_.Exception.Response.GetResponseStream())
$responseBody = $reader.ReadToEnd()
Write-Host "Détails: $responseBody" -ForegroundColor Red
}
}