fixing auth-build konflikte

This commit is contained in:
2025-10-04 13:28:41 +02:00
parent dabb7bf5e3
commit 1ed5f3bfca
7 changed files with 34 additions and 10 deletions
+5 -4
View File
@@ -47,7 +47,7 @@ zipkinReporter = "3.5.1"
# --- Authentication --- # --- Authentication ---
auth0Jwt = "4.5.0" auth0Jwt = "4.5.0"
keycloak = "26.4.0" keycloakAdminClient = "26.0.7"
# --- Testing --- # --- Testing ---
junitJupiter = "5.12.2" junitJupiter = "5.12.2"
@@ -55,7 +55,7 @@ junitPlatform = "1.12.2"
mockk = "1.14.5" mockk = "1.14.5"
assertj = "3.27.4" assertj = "3.27.4"
testcontainers = "1.21.3" testcontainers = "1.21.3"
testcontainersKeycloak = "3.8.0" testcontainersKeycloak = "3.9.0"
# --- Resilience4j --- # --- Resilience4j ---
resilience4j = "2.3.0" resilience4j = "2.3.0"
@@ -162,7 +162,7 @@ spring-boot-starter-aop = { module = "org.springframework.boot:spring-boot-start
# --- Authentication --- # --- Authentication ---
auth0-java-jwt = { module = "com.auth0:java-jwt", version.ref = "auth0Jwt" } auth0-java-jwt = { module = "com.auth0:java-jwt", version.ref = "auth0Jwt" }
keycloak-admin-client = { module = "org.keycloak:keycloak-admin-client", version.ref = "keycloak" } keycloak-admin-client = { module = "org.keycloak:keycloak-admin-client", version.ref = "keycloakAdminClient" }
# --- Utilities --- # --- Utilities ---
uuid = { module = "com.benasher44:uuid", version.ref = "uuid" } uuid = { module = "com.benasher44:uuid", version.ref = "uuid" }
@@ -272,7 +272,8 @@ testing-jvm = [
testcontainers = [ testcontainers = [
"testcontainers-core", "testcontainers-core",
"testcontainers-junit-jupiter", "testcontainers-junit-jupiter",
"testcontainers-postgresql" "testcontainers-postgresql",
"testcontainers-keycloak"
] ]
# Bündelt alle Abhängigkeiten, die ein Service für Metriken und Tracing benötigt. # Bündelt alle Abhängigkeiten, die ein Service für Metriken und Tracing benötigt.
monitoring-client = [ monitoring-client = [
Vendored
+1 -1
View File
@@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# #
# Copyright © 2015-2021 the original authors. # Copyright © 2015 the original authors.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@@ -33,8 +33,10 @@ dependencies {
// Spring Security für die Absicherung des Servers. // Spring Security für die Absicherung des Servers.
implementation(libs.spring.boot.starter.security) implementation(libs.spring.boot.starter.security)
implementation(libs.spring.boot.starter.oauth2.resource.server) implementation(libs.spring.boot.starter.oauth2.resource.server)
// Keycloak Admin Client zur Verwaltung von Benutzern und Realms. // Keycloak Admin Client zur Verwaltung von Benutzern und Realms.
implementation(libs.keycloak.admin.client) implementation(libs.keycloak.admin.client)
// API-Dokumentation mit OpenAPI/Swagger. // API-Dokumentation mit OpenAPI/Swagger.
implementation(libs.springdoc.openapi.starter.webmvc.ui) implementation(libs.springdoc.openapi.starter.webmvc.ui)
// Monitoring und Metriken für Production-Readiness. // Monitoring und Metriken für Production-Readiness.
@@ -3,9 +3,24 @@ package at.mocode.infrastructure.auth
import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication import org.springframework.boot.runApplication
/**
* Hauptklasse für den Auth-Server.
*
* Dieser Service fungiert als zentraler Authentifizierungs- und Autorisierungsserver,
* der mit Keycloak kommuniziert und JWT-Token-Management bereitstellt.
*
* Funktionalitäten:
* - JWT Token Generation und Validierung
* - Integration mit Keycloak
* - Benutzer- und Berechtigungsverwaltung
* - REST API für Authentifizierung
*/
@SpringBootApplication @SpringBootApplication
class AuthServerApplication class AuthServerApplication
/**
* Haupteinstiegspunkt für den Auth-Server Service
*/
fun main(args: Array<String>) { fun main(args: Array<String>) {
runApplication<AuthServerApplication>(*args) runApplication<AuthServerApplication>(*args)
} }
@@ -29,7 +29,7 @@ import java.time.Duration
class KeycloakIntegrationTest { class KeycloakIntegrationTest {
companion object { companion object {
private const val KEYCLOAK_VERSION = "25.0.2" private const val KEYCLOAK_VERSION = "26.4.0"
private const val KEYCLOAK_PORT = 8080 private const val KEYCLOAK_PORT = 8080
private const val KEYCLOAK_ADMIN_USER = "admin" private const val KEYCLOAK_ADMIN_USER = "admin"
private const val KEYCLOAK_ADMIN_PASSWORD = "admin" private const val KEYCLOAK_ADMIN_PASSWORD = "admin"
+6
View File
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
// Dieses Modul ist das API-Gateway und der einzige öffentliche Einstiegspunkt // Dieses Modul ist das API-Gateway und der einzige öffentliche Einstiegspunkt
// für alle externen Anfragen an das Meldestelle-System. // für alle externen Anfragen an das Meldestelle-System.
plugins { plugins {
@@ -104,3 +106,7 @@ tasks.register<Test>("integrationTest") {
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
} }
} }
val compileKotlin: KotlinCompile by tasks
compileKotlin.compilerOptions {
freeCompilerArgs.set(listOf("-Xannotation-default-target=param-property"))
}
@@ -8,8 +8,8 @@ import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Configuration
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity
import org.springframework.security.config.web.server.ServerHttpSecurity import org.springframework.security.config.web.server.ServerHttpSecurity
import org.springframework.security.oauth2.jwt.ReactiveJwtDecoder
import org.springframework.security.oauth2.jwt.NimbusReactiveJwtDecoder import org.springframework.security.oauth2.jwt.NimbusReactiveJwtDecoder
import org.springframework.security.oauth2.jwt.ReactiveJwtDecoder
import org.springframework.security.web.server.SecurityWebFilterChain import org.springframework.security.web.server.SecurityWebFilterChain
import org.springframework.web.cors.CorsConfiguration import org.springframework.web.cors.CorsConfiguration
import org.springframework.web.cors.reactive.CorsConfigurationSource import org.springframework.web.cors.reactive.CorsConfigurationSource
@@ -66,8 +66,8 @@ import java.time.Duration
@EnableConfigurationProperties(GatewaySecurityProperties::class) @EnableConfigurationProperties(GatewaySecurityProperties::class)
class SecurityConfig( class SecurityConfig(
private val securityProperties: GatewaySecurityProperties, private val securityProperties: GatewaySecurityProperties,
@Value("\${keycloak.issuer-uri:}") private val issuerUri: String, @Value($$"${keycloak.issuer-uri:}") private val issuerUri: String,
@Value("\${keycloak.jwk-set-uri:}") private val jwkSetUri: String @Value($$"${keycloak.jwk-set-uri:}") private val jwkSetUri: String
) { ) {
/** /**
@@ -75,7 +75,7 @@ class SecurityConfig(
* *
* Diese Methode konfiguriert die reaktive Sicherheits-Filterkette mit: * Diese Methode konfiguriert die reaktive Sicherheits-Filterkette mit:
* - CSRF deaktiviert für zustandslosen API-Betrieb * - CSRF deaktiviert für zustandslosen API-Betrieb
* - Expliziter CORS-Konfiguration für Cross-Origin-Unterstützung * - Explizite CORS-Konfiguration für Cross-Origin-Unterstützung
* - Permissiver Autorisierung (Authentifizierung durch den JWT-Filter) * - Permissiver Autorisierung (Authentifizierung durch den JWT-Filter)
* *
* Die Konfiguration bleibt kompatibel mit der bestehenden Filterarchitektur * Die Konfiguration bleibt kompatibel mit der bestehenden Filterarchitektur