App-Code: - KeycloakOidcTokenProvider: PKCE-Login via flutter_appauth, Refresh via Refresh-Token aus flutter_secure_storage, Session-Restore beim App-Start, Logout. - AuthSessionEvent als Provider→Bloc-Brücke (LoggedIn/LoggedOut/ SessionExpired) auf einem Broadcast-Stream. - AuthBloc komplett umgebaut: nimmt jetzt den KeycloakOidcTokenProvider statt UserInfoService, mappt eingehende Provider-Events auf eigene Zustände. Authenticated.fromClaims() liest personalnummer + Name aus dem ID-Token-Payload. - LoginPage: kein Browser+Deep-Link mehr — Button feuert LoginRequested, der Provider übernimmt den restlichen Flow. - network_locator: produktiver KeycloakOidcTokenProvider, doppelt registriert (KeycloakOidcTokenProvider für AuthBloc, AuthTokenProvider für Interceptor). - Auth-State trägt zusätzlich personalnummer/displayName/email; das Legacy-User-Objekt + sessionId bleiben temporär drin, damit die alten ERPframe-Services (Phase D) noch kompilieren. Plattform-Setup: - Android: appAuthRedirectScheme=holzleitner in build.gradle.kts, NetworkSecurityConfig erlaubt HTTP zu localhost/10.0.2.2/127.0.0.1. - iOS: holzleitner als URL-Scheme im Info.plist, ATS-Ausnahme für localhost (HTTP-Keycloak im Dev-Setup). Out of scope: - Keine echte App-Run-Smoke — kommt mit dem User-Test. - iOS-pod-install läuft beim ersten 'flutter run ios' automatisch. - Old ERPframe-Services bleiben aktiv und werfen ab jetzt 401 (kein Cookie-Session-Token mehr) — wird in Phase D entfernt.
100 lines
3.7 KiB
Dart
100 lines
3.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
import 'package:hl_lieferservice/feature/authentication/bloc/auth_bloc.dart';
|
|
import 'package:hl_lieferservice/feature/authentication/bloc/auth_event.dart';
|
|
import 'package:hl_lieferservice/feature/authentication/bloc/auth_state.dart';
|
|
|
|
/// Login-Page nach der Migration auf Keycloak OIDC (Phase B).
|
|
///
|
|
/// Der eigentliche Flow läuft komplett im `AuthBloc` →
|
|
/// `KeycloakOidcTokenProvider.login()`: `flutter_appauth` öffnet einen
|
|
/// Browser-Tab, der RedirectURI `holzleitner://oauth2redirect` kommt
|
|
/// zurück, der Code wird gegen Tokens getauscht.
|
|
class LoginPage extends StatelessWidget {
|
|
const LoginPage({super.key, this.sessionExpired = false});
|
|
|
|
final bool sessionExpired;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(),
|
|
body: Column(
|
|
children: [
|
|
if (sessionExpired)
|
|
MaterialBanner(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
content: const Text(
|
|
'Deine Sitzung ist abgelaufen. Bitte melde dich erneut an.',
|
|
style: TextStyle(color: Colors.white),
|
|
),
|
|
backgroundColor: Colors.orange.shade800,
|
|
leading: const Icon(
|
|
Icons.warning_amber_rounded,
|
|
color: Colors.white,
|
|
),
|
|
actions: const [SizedBox.shrink()],
|
|
),
|
|
Expanded(
|
|
child: Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.all(50),
|
|
child: Column(
|
|
children: [
|
|
Image.asset(
|
|
'assets/holzleitner_Logo_2017_RZ_transparent.png',
|
|
),
|
|
const Padding(
|
|
padding: EdgeInsets.only(top: 20),
|
|
child: Text(
|
|
'Auslieferservice',
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.w400,
|
|
fontSize: 20,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
FractionallySizedBox(
|
|
widthFactor: 0.8,
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(top: 15, bottom: 15),
|
|
child: BlocBuilder<AuthBloc, AuthState>(
|
|
builder: (context, state) {
|
|
if (state is Authenticating) {
|
|
return Column(
|
|
children: const [
|
|
CircularProgressIndicator(),
|
|
SizedBox(height: 16),
|
|
Text('Anmeldung wird abgeschlossen…'),
|
|
],
|
|
);
|
|
}
|
|
return OutlinedButton(
|
|
onPressed: () => context.read<AuthBloc>().add(
|
|
const LoginRequested(),
|
|
),
|
|
child: const Text(
|
|
'Anmelden mit Holzleitner Login',
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|