- BackendConfig.localDev nutzt jetzt die LAN-IP des Dev-Macs (192.168.0.138) statt localhost. Notwendig zum Testen auf einem realen Android-Gerät über WLAN. Auf dem iOS-Simulator zurückwechseln oder per Build-Flag injizieren. - AuthBloc.on<SessionExpiredEvent> wird zum No-Op (mit Log). Begründung: die alten ERPframe-Repos rufen das nach jedem 401 auf, weil ihr Cookie-Login serverseitig weg ist. Solange Phase D diese Repos nicht ersetzt hat, wäre ein echter Logout daraus fatal — der erste TourBloc-Load nach Keycloak-Login würde die Session sofort wieder wegwerfen. Die legitime SessionExpired-Quelle bleibt der Provider-Stream (Refresh-Failure). - CarSelectionPage hat jetzt durchgehend eine AppBar (vorher nur im 'wechseln'-Modus) plus ein Account-Popup oben rechts mit Personalnummer + roter Abmelden-Aktion. Der Drawer ist sonst nur an Home, und solange Cars-Loading per 401 blockt, kommt der User ohne Pre-Home-Logout nicht raus.
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://192.168.0.138:3000',
|
|
keycloakIssuerUrl: 'http://192.168.0.138:8080/realms/holzleitner',
|
|
keycloakClientId: 'holzleitner-app',
|
|
keycloakRedirectUrl: 'holzleitner://oauth2redirect',
|
|
);
|
|
}
|