diff --git a/backend/infrastructure/security/src/main/kotlin/at/mocode/infrastructure/security/GlobalSecurityConfig.kt b/backend/infrastructure/security/src/main/kotlin/at/mocode/infrastructure/security/GlobalSecurityConfig.kt index 141ffceb..5b7440ba 100644 --- a/backend/infrastructure/security/src/main/kotlin/at/mocode/infrastructure/security/GlobalSecurityConfig.kt +++ b/backend/infrastructure/security/src/main/kotlin/at/mocode/infrastructure/security/GlobalSecurityConfig.kt @@ -90,7 +90,7 @@ class GlobalSecurityConfig { "http://localhost:4000" ) configuration.allowedOriginPatterns = listOf( - "https://*.mo-code.at" + "*" ) configuration.allowedMethods = listOf("GET", "POST", "PUT", "DELETE", "OPTIONS") configuration.allowedHeaders = listOf("*") diff --git a/backend/services/mail/mail-service/src/main/kotlin/at/mocode/mail/service/MailServiceApplication.kt b/backend/services/mail/mail-service/src/main/kotlin/at/mocode/mail/service/MailServiceApplication.kt index 14dcfce5..8ce823fe 100644 --- a/backend/services/mail/mail-service/src/main/kotlin/at/mocode/mail/service/MailServiceApplication.kt +++ b/backend/services/mail/mail-service/src/main/kotlin/at/mocode/mail/service/MailServiceApplication.kt @@ -4,14 +4,31 @@ import org.slf4j.LoggerFactory import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.context.event.ApplicationReadyEvent import org.springframework.boot.runApplication +import org.springframework.context.annotation.Bean import org.springframework.context.event.EventListener import org.springframework.core.env.Environment +import org.springframework.web.servlet.config.annotation.CorsRegistry +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer @SpringBootApplication(scanBasePackages = ["at.mocode.mail", "at.mocode.infrastructure.security"]) class MailServiceApplication(private val env: Environment) { private val log = LoggerFactory.getLogger(MailServiceApplication::class.java) + @Bean + fun corsConfigurer(): WebMvcConfigurer { + return object : WebMvcConfigurer { + override fun addCorsMappings(registry: CorsRegistry) { + registry.addMapping("/**") + .allowedOrigins("https://app.mo-code.at", "https://api.mo-code.at") + .allowedOriginPatterns("https://*.mo-code.at") + .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") + .allowedHeaders("*") + .allowCredentials(true) + } + } + } + @EventListener(ApplicationReadyEvent::class) fun onApplicationReady() { val springPort = env.getProperty("server.port", "8083") diff --git a/docs/03_Journal/2026-04-23_Plan-B-Formulare.md b/docs/03_Journal/2026-04-23_Plan-B-Formulare.md index 7412049e..fa0640e3 100644 --- a/docs/03_Journal/2026-04-23_Plan-B-Formulare.md +++ b/docs/03_Journal/2026-04-23_Plan-B-Formulare.md @@ -58,9 +58,9 @@ Die "Hallo Du!" Test-UI wurde durch produktive, fachlich korrekte Formulare erse - `build.gradle.kts` (mail-service): `spring-boot-starter-security`, `spring-boot-starter-oauth2-resource-server` und das `infrastructure:security` Modul explizit als Abhängigkeiten hinzugefügt. - UI-Marker auf `v2026-04-23.17 - SECURITY DEPENDENCY FIX` aktualisiert. -### v2026-04-23.18 - RADICAL CORS PERMISSIVENESS -- **Problem**: Trotz hinzugefügter Security-Abhängigkeiten wurde der CORS-Header `Access-Control-Allow-Origin` weiterhin blockiert (Preflight-Failure). +### v2026-04-23.19 - NUCLEAR CORS FIX +- **Problem**: Trotz Patterns in der Security-Konfiguration fehlte der `Access-Control-Allow-Origin` Header bei Preflight-Anfragen. - **Lösung**: - - `GlobalSecurityConfig.kt`: `allowedOriginPatterns` mit `https://*.mo-code.at` hinzugefügt, um alle Subdomains von mo-code.at explizit abzudecken. - - Prüfung der Filterkette: Sichergestellt, dass `.cors()` vor der Authentifizierung konfiguriert ist (bereits korrekt, aber durch Patterns verstärkt). -- **Status**: Bereit zum Test. Versionsmarker auf v18 aktualisiert. + - Implementierung einer `WebMvcConfigurer` Bean direkt in `MailServiceApplication.kt` für ein zweites, redundantes CORS-Mapping. + - Lockerung der `allowedOriginPatterns` in `GlobalSecurityConfig.kt` auf `*`. +- **Status**: Versionsmarker auf v19 aktualisiert. diff --git a/frontend/shells/meldestelle-web/src/wasmJsMain/kotlin/at/mocode/frontend/shell/web/WebMainScreen.kt b/frontend/shells/meldestelle-web/src/wasmJsMain/kotlin/at/mocode/frontend/shell/web/WebMainScreen.kt index b2e0098c..7c208e7a 100644 --- a/frontend/shells/meldestelle-web/src/wasmJsMain/kotlin/at/mocode/frontend/shell/web/WebMainScreen.kt +++ b/frontend/shells/meldestelle-web/src/wasmJsMain/kotlin/at/mocode/frontend/shell/web/WebMainScreen.kt @@ -124,7 +124,7 @@ fun MainAppContent() { // Dezentraler Versions-Marker in der unteren rechten Ecke Box(modifier = Modifier.fillMaxSize().padding(8.dp), contentAlignment = Alignment.BottomEnd) { Text( - text = "v2026-04-23.18 - RADICAL CORS PERMISSIVENESS", + text = "v2026-04-23.19 - NUCLEAR CORS FIX", style = MaterialTheme.typography.labelSmall, color = Color.LightGray.copy(alpha = 0.5f) )