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.
57 lines
2.2 KiB
Dart
57 lines
2.2 KiB
Dart
/// Endpoint-Konfiguration für das Rust-Backend.
|
|
///
|
|
/// Diese Übergangs-Konfiguration für die Backend-Migration wird in
|
|
/// Phase D durch eine umfassendere Konfigurations-Ablösung verfeinert
|
|
/// (Build-Time-Flavor pro Stage etc.).
|
|
///
|
|
/// **Werte für lokale Entwicklung:**
|
|
/// * iOS-Simulator + macOS-Host: `http://localhost:...`
|
|
/// * Android-Emulator: `http://10.0.2.2:...`
|
|
/// * Echtes Gerät im LAN: `http://<host-IP>:...`
|
|
///
|
|
/// Default ist iOS-Simulator-tauglich; für Android-Build vor dem
|
|
/// Compile umstellen oder per Build-Flag injizieren.
|
|
class BackendConfig {
|
|
const BackendConfig({
|
|
required this.apiBaseUrl,
|
|
required this.keycloakIssuerUrl,
|
|
required this.keycloakClientId,
|
|
required this.keycloakRedirectUrl,
|
|
});
|
|
|
|
/// Basis-URL der Rust-API (kein abschließender Slash).
|
|
final String apiBaseUrl;
|
|
|
|
/// Realm-Issuer ohne `/.well-known/...`-Suffix —
|
|
/// `flutter_appauth` hängt das selbst an für die Discovery.
|
|
/// Beispiel: `http://localhost:8080/realms/holzleitner`.
|
|
///
|
|
/// **Achtung:** Keycloak prägt das `iss`-Claim aus dem Hostnamen
|
|
/// dieser URL. Das Backend erwartet exakt diesen String als
|
|
/// `KEYCLOAK_ISSUER_URL`. Mismatch → 401 mit `invalid issuer`.
|
|
final String keycloakIssuerUrl;
|
|
|
|
/// Token-Endpoint des Realms — abgeleitet aus dem Issuer.
|
|
String get keycloakTokenEndpoint =>
|
|
'$keycloakIssuerUrl/protocol/openid-connect/token';
|
|
|
|
/// Public-Client-Id (entspricht der `aud` im Backend-Token).
|
|
final String keycloakClientId;
|
|
|
|
/// Custom-Scheme-Redirect, das in Keycloak als
|
|
/// `holzleitner://oauth2redirect` whitelisted ist. Muss mit dem
|
|
/// `appAuthRedirectScheme` in `android/app/build.gradle.kts` und
|
|
/// dem `CFBundleURLSchemes`-Eintrag in `ios/Runner/Info.plist`
|
|
/// matchen.
|
|
final String keycloakRedirectUrl;
|
|
|
|
/// Default-Konfiguration für lokale Entwicklung gegen das
|
|
/// Docker-Compose-Setup (Postgres + Keycloak + Backend).
|
|
static const BackendConfig localDev = BackendConfig(
|
|
apiBaseUrl: 'http://localhost:3000',
|
|
keycloakIssuerUrl: 'http://localhost:8080/realms/holzleitner',
|
|
keycloakClientId: 'holzleitner-app',
|
|
keycloakRedirectUrl: 'holzleitner://oauth2redirect',
|
|
);
|
|
}
|