### fix: behebe CORS- und Config-Probleme
All checks were successful
All checks were successful
- **MailServiceApplication:** Füge `scanBasePackages` hinzu, um `GlobalSecurityConfig` korrekt zu laden. - **GlobalSecurityConfig:** Erlaube Zugriff auf `/api/mail/nennung` ohne Authentifizierung. - **MailController:** Entferne redundante `@CrossOrigin` Annotation. - **UI:** Aktualisiere Versionsmarker auf `v2026-04-23.16 - CORS & CONFIG FIX`.
This commit is contained in:
parent
3244efd5e0
commit
5c51664e6c
|
|
@ -35,6 +35,8 @@ class GlobalSecurityConfig {
|
|||
// Explizite Freigaben (Health, Information, Public-Endpoints)
|
||||
auth.requestMatchers("/actuator/**").permitAll()
|
||||
auth.requestMatchers("/api/v1/devices/register").permitAll() // Onboarding erlauben
|
||||
auth.requestMatchers("/api/mail/nennung").permitAll() // Plan-B Nennungen erlauben
|
||||
auth.requestMatchers("/api/mail/nennungen").authenticated() // Liste schützen
|
||||
auth.requestMatchers("/ping/public").permitAll()
|
||||
auth.requestMatchers("/ping/simple").permitAll()
|
||||
auth.requestMatchers("/ping/health").permitAll()
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import org.springframework.boot.runApplication
|
|||
import org.springframework.context.event.EventListener
|
||||
import org.springframework.core.env.Environment
|
||||
|
||||
@SpringBootApplication
|
||||
@SpringBootApplication(scanBasePackages = ["at.mocode.mail", "at.mocode.infrastructure.security"])
|
||||
class MailServiceApplication(private val env: Environment) {
|
||||
|
||||
private val log = LoggerFactory.getLogger(MailServiceApplication::class.java)
|
||||
|
|
|
|||
|
|
@ -39,11 +39,6 @@ data class NennungRequest(
|
|||
@OptIn(ExperimentalUuidApi::class)
|
||||
@RestController
|
||||
@RequestMapping("/api/mail")
|
||||
@CrossOrigin(
|
||||
origins = ["http://localhost:8080", "https://nennung.mo-code.at", "https://app.mo-code.at", "https://api.mo-code.at"],
|
||||
allowedHeaders = ["*"],
|
||||
methods = [RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE, RequestMethod.OPTIONS]
|
||||
) // Für Wasm-Web-App (Compose HTML/Wasm)
|
||||
class MailController(
|
||||
private val nennungRepository: NennungRepository,
|
||||
private val mailSender: JavaMailSender
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@ Die "Hallo Du!" Test-UI wurde durch produktive, fachlich korrekte Formulare erse
|
|||
- `MailController.kt`: `@CrossOrigin` um explizite Header (`allowedHeaders = ["*"]`) und Methoden (`methods = [...]`) erweitert, um Preflight-Checks (OPTIONS) korrekt zu bedienen.
|
||||
- UI-Marker auf `v2026-04-23.14 - CORS REANIMATION` aktualisiert.
|
||||
|
||||
### 2026-04-23 11:00 - Version 15: CORS Stability & Test Fix
|
||||
- **Problem**: Aktivierung von `.cors { }` in `GlobalSecurityConfig.kt` verursachte `NoSuchBeanDefinitionException` in Spring-Integration-Tests, da keine `CorsConfigurationSource` Bean definiert war.
|
||||
### 2026-04-23 11:15 - Version 16: CORS & Config Final Fix
|
||||
- **Problem**: CORS-Fehler bestanden weiterhin, da der `mail-service` die `GlobalSecurityConfig` nicht geladen hatte (`scanBasePackages` fehlte). Zudem blockierte die Sicherheitskonfiguration den Zugriff auf `/api/mail/nennung`, da sie standardmäßig Authentifizierung erforderte.
|
||||
- **Lösung**:
|
||||
- `GlobalSecurityConfig.kt`: Explizite `CorsConfigurationSource` Bean implementiert, die sowohl lokale Entwicklungsumgebungen (`localhost`) als auch produktive URLs (`*.mo-code.at`) whitelisted.
|
||||
- Integration von `it.configurationSource(corsConfigurationSource())` in die `filterChain` zur Behebung der Testfehler.
|
||||
- UI-Marker auf `v2026-04-23.15 - CORS STABILITY` aktualisiert.
|
||||
- Verifiziert durch erfolgreichen Durchlauf des `EntriesIsolationIntegrationTest`.
|
||||
- `MailServiceApplication.kt`: `scanBasePackages` hinzugefügt, damit die `GlobalSecurityConfig` auch im `mail-service` aktiv wird.
|
||||
- `GlobalSecurityConfig.kt`: `/api/mail/nennung` explizit in die `.permitAll()` Liste aufgenommen, damit das Formular ohne Login abgeschickt werden kann.
|
||||
- `MailController.kt`: Redundante `@CrossOrigin` Annotation entfernt (wird nun zentral via Bean gesteuert).
|
||||
- UI-Marker auf `v2026-04-23.16 - CORS & CONFIG FIX` aktualisiert.
|
||||
|
|
|
|||
|
|
@ -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.15 - CORS STABILITY",
|
||||
text = "v2026-04-23.16 - CORS & CONFIG FIX",
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = Color.LightGray.copy(alpha = 0.5f)
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user