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:
46
fix-keycloak-package-name.ps1
Normal file
46
fix-keycloak-package-name.ps1
Normal file
@@ -0,0 +1,46 @@
|
||||
# Script pour corriger le package name dans Keycloak
|
||||
$KeycloakUrl = "http://192.168.1.11:8180"
|
||||
$Realm = "unionflow"
|
||||
$ClientId = "unionflow-mobile"
|
||||
|
||||
Write-Host "=== CORRECTION DU PACKAGE NAME KEYCLOAK ===" -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
|
||||
|
||||
# Récupérer le client
|
||||
$headers = @{ "Authorization" = "Bearer $accessToken" }
|
||||
$clients = Invoke-RestMethod -Uri "$KeycloakUrl/admin/realms/$Realm/clients?clientId=$ClientId" -Method Get -Headers $headers
|
||||
$client = $clients[0]
|
||||
$clientUuid = $client.id
|
||||
|
||||
Write-Host "Client trouvé: $clientUuid" -ForegroundColor Green
|
||||
Write-Host "Redirect URIs actuelles:" -ForegroundColor Yellow
|
||||
foreach ($uri in $client.redirectUris) {
|
||||
Write-Host " - $uri" -ForegroundColor Gray
|
||||
}
|
||||
|
||||
# Mettre à jour avec le bon package name
|
||||
$client.redirectUris = @(
|
||||
"dev.lions.unionflow_mobile_apps://callback",
|
||||
"dev.lions.unionflow_mobile_apps://login-callback",
|
||||
"dev.lions.unionflow_mobile_apps://oauth/callback"
|
||||
)
|
||||
|
||||
$client.webOrigins = @("+")
|
||||
|
||||
# Convertir en JSON et mettre à jour
|
||||
$clientJson = $client | ConvertTo-Json -Depth 10
|
||||
Invoke-RestMethod -Uri "$KeycloakUrl/admin/realms/$Realm/clients/$clientUuid" -Method Put -Headers $headers -Body $clientJson -ContentType "application/json"
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "✅ Package name corrigé dans Keycloak:" -ForegroundColor Green
|
||||
Write-Host " - dev.lions.unionflow_mobile_apps://callback" -ForegroundColor Gray
|
||||
Write-Host " - dev.lions.unionflow_mobile_apps://login-callback" -ForegroundColor Gray
|
||||
Write-Host " - dev.lions.unionflow_mobile_apps://oauth/callback" -ForegroundColor Gray
|
||||
|
||||
} catch {
|
||||
Write-Host "Erreur: $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
Reference in New Issue
Block a user