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

@@ -15,6 +15,8 @@ import 'package:unionflow_mobile_apps/core/auth/services/auth_api_service.dart'
as _i705;
import 'package:unionflow_mobile_apps/core/auth/services/auth_service.dart'
as _i423;
import 'package:unionflow_mobile_apps/core/auth/services/keycloak_webview_auth_service.dart'
as _i68;
import 'package:unionflow_mobile_apps/core/auth/storage/secure_token_storage.dart'
as _i394;
import 'package:unionflow_mobile_apps/core/network/auth_interceptor.dart'
@@ -27,6 +29,12 @@ import 'package:unionflow_mobile_apps/features/cotisations/domain/repositories/c
as _i961;
import 'package:unionflow_mobile_apps/features/cotisations/presentation/bloc/cotisations_bloc.dart'
as _i919;
import 'package:unionflow_mobile_apps/features/evenements/data/repositories/evenement_repository_impl.dart'
as _i947;
import 'package:unionflow_mobile_apps/features/evenements/domain/repositories/evenement_repository.dart'
as _i351;
import 'package:unionflow_mobile_apps/features/evenements/presentation/bloc/evenement_bloc.dart'
as _i1001;
import 'package:unionflow_mobile_apps/features/members/data/repositories/membre_repository_impl.dart'
as _i108;
import 'package:unionflow_mobile_apps/features/members/domain/repositories/membre_repository.dart'
@@ -45,29 +53,34 @@ extension GetItInjectableX on _i174.GetIt {
environment,
environmentFilter,
);
gh.singleton<_i68.KeycloakWebViewAuthService>(
() => _i68.KeycloakWebViewAuthService());
gh.singleton<_i394.SecureTokenStorage>(() => _i394.SecureTokenStorage());
gh.singleton<_i772.AuthInterceptor>(() => _i772.AuthInterceptor());
gh.singleton<_i978.DioClient>(() => _i978.DioClient());
gh.singleton<_i705.AuthApiService>(
() => _i705.AuthApiService(gh<_i978.DioClient>()));
gh.singleton<_i238.ApiService>(
() => _i238.ApiService(gh<_i978.DioClient>()));
gh.singleton<_i772.AuthInterceptor>(
() => _i772.AuthInterceptor(gh<_i394.SecureTokenStorage>()));
gh.lazySingleton<_i961.CotisationRepository>(
() => _i991.CotisationRepositoryImpl(gh<_i238.ApiService>()));
gh.lazySingleton<_i930.MembreRepository>(
() => _i108.MembreRepositoryImpl(gh<_i238.ApiService>()));
gh.factory<_i41.MembresBloc>(
() => _i41.MembresBloc(gh<_i930.MembreRepository>()));
gh.singleton<_i423.AuthService>(() => _i423.AuthService(
gh<_i394.SecureTokenStorage>(),
gh<_i705.AuthApiService>(),
gh<_i772.AuthInterceptor>(),
gh<_i978.DioClient>(),
));
gh.singleton<_i635.AuthBloc>(() => _i635.AuthBloc(gh<_i423.AuthService>()));
gh.lazySingleton<_i961.CotisationRepository>(
() => _i991.CotisationRepositoryImpl(gh<_i238.ApiService>()));
gh.lazySingleton<_i351.EvenementRepository>(
() => _i947.EvenementRepositoryImpl(gh<_i238.ApiService>()));
gh.lazySingleton<_i930.MembreRepository>(
() => _i108.MembreRepositoryImpl(gh<_i238.ApiService>()));
gh.factory<_i1001.EvenementBloc>(
() => _i1001.EvenementBloc(gh<_i351.EvenementRepository>()));
gh.factory<_i41.MembresBloc>(
() => _i41.MembresBloc(gh<_i930.MembreRepository>()));
gh.factory<_i919.CotisationsBloc>(
() => _i919.CotisationsBloc(gh<_i961.CotisationRepository>()));
gh.singleton<_i635.AuthBloc>(() => _i635.AuthBloc(gh<_i423.AuthService>()));
return this;
}
}