Files
unionflow-server-api/unionflow-mobile-apps/lib/main.dart
DahoudG f89f6167cc 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
2025-09-15 01:44:16 +00:00

79 lines
2.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'core/auth/presentation/auth_wrapper.dart';
import 'core/di/injection.dart';
import 'shared/theme/app_theme.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Initialisation des données de localisation
await initializeDateFormatting('fr_FR', null);
// Configuration de l'injection de dépendances
await configureDependencies();
// Le service d'authentification WebView s'initialise automatiquement
// Configuration du système
await _configureApp();
// Lancement de l'application
runApp(const UnionFlowApp());
}
/// Configure les paramètres globaux de l'application
Future<void> _configureApp() async {
// Configuration de l'orientation
await SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);
// Configuration de la barre de statut
SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.dark,
statusBarBrightness: Brightness.light,
systemNavigationBarColor: Colors.white,
systemNavigationBarIconBrightness: Brightness.dark,
),
);
}
/// Application principale
class UnionFlowApp extends StatelessWidget {
const UnionFlowApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'UnionFlow',
debugShowCheckedModeBanner: false,
// Configuration du thème
theme: AppTheme.lightTheme,
darkTheme: AppTheme.darkTheme,
themeMode: ThemeMode.system,
// Configuration de la localisation
locale: const Locale('fr', 'FR'),
// Application principale
home: const AuthWrapper(),
// Builder global pour gérer les erreurs
builder: (context, child) {
return MediaQuery(
data: MediaQuery.of(context).copyWith(
textScaler: const TextScaler.linear(1.0),
),
child: child ?? const SizedBox(),
);
},
);
}
}