From 4d1e7d44df1b3adee3808b4c1ce48f467adbf904 Mon Sep 17 00:00:00 2001 From: Jonas-Ian Kuche Date: Tue, 30 Jul 2024 14:02:36 +0200 Subject: [PATCH] chore: update dependencies --- Dockerfile | 11 +- build.gradle.kts | 29 ++- gradle/wrapper/gradle-wrapper.properties | 3 +- gradlew.bat | 178 +++++++++--------- .../classroom/config/SerializationConfig.kt | 2 +- .../properties/ClassroomProperties.kt | 2 - .../ii/classroom/properties/JwtProperties.kt | 2 - .../properties/UpstreamBBBProperties.kt | 2 - .../security/SecurityConfiguration.kt | 2 + .../classroom/ClassroomRSocketJwtSecurity.kt | 15 +- src/main/resources/application.yml | 1 - 11 files changed, 118 insertions(+), 129 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5569f2c..a9773d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,7 @@ -FROM gradle:6.8.3-jdk11 AS cache-gradle +ARG GRADLE_VERSION=8.9.0-jdk21 +ARG JDK_VERSION=21 + +FROM gradle:$GRADLE_VERSION AS cache-gradle RUN mkdir /cache-gradle RUN mkdir /code ENV GRADLE_USER_HOME /cache-gradle @@ -6,20 +9,20 @@ COPY build.gradle.kts /code WORKDIR /code RUN gradle clean build -i -x bootJar -FROM gradle:6.8.3-jdk11 AS build-node +FROM gradle:$GRADLE_VERSION AS build-node COPY ./ /build WORKDIR /build/web-gui RUN rm -rf node_modules RUN gradle installDist -FROM gradle:6.8.3-jdk11 AS build-gradle +FROM gradle:$GRADLE_VERSION AS build-gradle COPY . /build/ COPY --from=cache-gradle /cache-gradle /home/gradle/.gradle COPY --from=build-node /build/web-gui/dist/web-gui/ /build/src/main/resources/static/ WORKDIR /build/ RUN gradle dist -i -x npm_run_clean -x npm_run_build -FROM openjdk:11-jdk-slim +FROM eclipse-temurin:$JDK_VERSION COPY --from=build-gradle /build/build/libs/digital-classroom-0.0.1-SNAPSHOT.jar /app/digital-classroom.jar EXPOSE 8085 ENTRYPOINT ["java","-jar","/app/digital-classroom.jar"] diff --git a/build.gradle.kts b/build.gradle.kts index 84dbf51..b2a87c6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,17 +1,16 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { - id("org.springframework.boot") version "2.5.6" - id("io.spring.dependency-management") version "1.0.11.RELEASE" + id("org.springframework.boot") version "3.3.2" + id("io.spring.dependency-management") version "1.1.6" idea - kotlin("jvm") version "1.4.32" - kotlin("plugin.spring") version "1.4.32" - kotlin("kapt") version "1.4.32" + kotlin("jvm") version "2.0.0" + kotlin("plugin.spring") version "2.0.0" } group = "de.thm.mni.ii" version = "0.0.1-SNAPSHOT" -java.sourceCompatibility = JavaVersion.VERSION_11 +java.sourceCompatibility = JavaVersion.VERSION_21 repositories { mavenCentral() @@ -29,29 +28,25 @@ dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor") implementation("javax.xml.bind:jaxb-api:2.3.1") - implementation("org.hibernate:hibernate-validator:6.0.16.Final") - implementation("commons-codec:commons-codec:1.15") - implementation("org.apache.commons:commons-lang3:3.12.0") - kapt("org.springframework.boot:spring-boot-configuration-processor") + implementation("org.hibernate:hibernate-validator:8.0.1.Final") + implementation("commons-codec:commons-codec:1.17.1") + implementation("org.apache.commons:commons-lang3:3.15.0") testImplementation("org.springframework.boot:spring-boot-starter-test") testImplementation("io.projectreactor:reactor-test") // Java 11 removed these Java EE modules implementation("javax.xml.bind:jaxb-api:2.3.1") - implementation("com.sun.xml.bind:jaxb-core:2.3.0.1") - implementation("com.sun.xml.bind:jaxb-impl:2.3.2") + implementation("com.sun.xml.bind:jaxb-core:4.0.5") + implementation("com.sun.xml.bind:jaxb-impl:4.0.5") + implementation("javax.validation:validation-api:2.0.1.Final") } tasks.withType { kotlinOptions { freeCompilerArgs = listOf("-Xjsr305=strict") - jvmTarget = "11" + jvmTarget = "21" } } -tasks.withType { - useJUnitPlatform() -} - tasks.register("dist") { dependsOn("build", "web-gui:copyWebToBackend") } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c709c72..19cfad9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -org.gradle.jvmargs=-Xmx2048m diff --git a/gradlew.bat b/gradlew.bat index 107acd3..ac1b06f 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,89 +1,89 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/src/main/kotlin/de/thm/mni/ii/classroom/config/SerializationConfig.kt b/src/main/kotlin/de/thm/mni/ii/classroom/config/SerializationConfig.kt index 8acf92e..13c61d5 100644 --- a/src/main/kotlin/de/thm/mni/ii/classroom/config/SerializationConfig.kt +++ b/src/main/kotlin/de/thm/mni/ii/classroom/config/SerializationConfig.kt @@ -39,7 +39,7 @@ class SerializationConfig : WebFluxConfigurer { fun objectMapper(): ObjectMapper { val om = ObjectMapper() om.registerModule(JavaTimeModule()) - om.registerModule(KotlinModule()) + om.registerModule(KotlinModule.Builder().build()) return om } diff --git a/src/main/kotlin/de/thm/mni/ii/classroom/properties/ClassroomProperties.kt b/src/main/kotlin/de/thm/mni/ii/classroom/properties/ClassroomProperties.kt index 2b5bfe3..cb9e189 100644 --- a/src/main/kotlin/de/thm/mni/ii/classroom/properties/ClassroomProperties.kt +++ b/src/main/kotlin/de/thm/mni/ii/classroom/properties/ClassroomProperties.kt @@ -1,11 +1,9 @@ package de.thm.mni.ii.classroom.properties import org.springframework.boot.context.properties.ConfigurationProperties -import org.springframework.boot.context.properties.ConstructorBinding import javax.validation.constraints.NotBlank @ConfigurationProperties(prefix = "classroom") -@ConstructorBinding data class ClassroomProperties( /** diff --git a/src/main/kotlin/de/thm/mni/ii/classroom/properties/JwtProperties.kt b/src/main/kotlin/de/thm/mni/ii/classroom/properties/JwtProperties.kt index e49a9c6..dd3fb1f 100644 --- a/src/main/kotlin/de/thm/mni/ii/classroom/properties/JwtProperties.kt +++ b/src/main/kotlin/de/thm/mni/ii/classroom/properties/JwtProperties.kt @@ -3,11 +3,9 @@ package de.thm.mni.ii.classroom.properties import org.hibernate.validator.constraints.Length import org.hibernate.validator.constraints.Range import org.springframework.boot.context.properties.ConfigurationProperties -import org.springframework.boot.context.properties.ConstructorBinding import javax.validation.constraints.NotBlank @ConfigurationProperties(prefix = "jwt") -@ConstructorBinding data class JwtProperties( /** diff --git a/src/main/kotlin/de/thm/mni/ii/classroom/properties/UpstreamBBBProperties.kt b/src/main/kotlin/de/thm/mni/ii/classroom/properties/UpstreamBBBProperties.kt index 1efc249..8ace6a7 100644 --- a/src/main/kotlin/de/thm/mni/ii/classroom/properties/UpstreamBBBProperties.kt +++ b/src/main/kotlin/de/thm/mni/ii/classroom/properties/UpstreamBBBProperties.kt @@ -1,11 +1,9 @@ package de.thm.mni.ii.classroom.properties import org.springframework.boot.context.properties.ConfigurationProperties -import org.springframework.boot.context.properties.ConstructorBinding import javax.validation.constraints.NotBlank @ConfigurationProperties(prefix = "upstream.bbb") -@ConstructorBinding data class UpstreamBBBProperties( @NotBlank val serviceUrl: String, diff --git a/src/main/kotlin/de/thm/mni/ii/classroom/security/SecurityConfiguration.kt b/src/main/kotlin/de/thm/mni/ii/classroom/security/SecurityConfiguration.kt index e10073c..10c4aae 100644 --- a/src/main/kotlin/de/thm/mni/ii/classroom/security/SecurityConfiguration.kt +++ b/src/main/kotlin/de/thm/mni/ii/classroom/security/SecurityConfiguration.kt @@ -4,6 +4,7 @@ import de.thm.mni.ii.classroom.security.classroom.ClassroomHttpJwtSecurity import de.thm.mni.ii.classroom.security.classroom.ClassroomHttpSessionTokenSecurity import de.thm.mni.ii.classroom.security.downstream.DownstreamAPISecurity import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration import org.springframework.http.HttpStatus import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity import org.springframework.security.config.web.server.SecurityWebFiltersOrder @@ -16,6 +17,7 @@ import kotlin.text.Charsets.UTF_8 /** * Main security configuration of the digital classroom. */ +@Configuration @EnableWebFluxSecurity class SecurityConfiguration( private val classroomHttpSessionTokenSecurity: ClassroomHttpSessionTokenSecurity, diff --git a/src/main/kotlin/de/thm/mni/ii/classroom/security/classroom/ClassroomRSocketJwtSecurity.kt b/src/main/kotlin/de/thm/mni/ii/classroom/security/classroom/ClassroomRSocketJwtSecurity.kt index ee9e408..3abf576 100644 --- a/src/main/kotlin/de/thm/mni/ii/classroom/security/classroom/ClassroomRSocketJwtSecurity.kt +++ b/src/main/kotlin/de/thm/mni/ii/classroom/security/classroom/ClassroomRSocketJwtSecurity.kt @@ -53,16 +53,13 @@ class ClassroomRSocketJwtSecurity { return mh } + private class JwtToAuthenticationConverter : Converter> { + override fun convert(source: Jwt): Mono = + Mono.just(source).map {jwt: Jwt -> ClassroomAuthentication(UserCredentials(jwt.claims), jwt.tokenValue)} + } + @Bean fun jwtToAuthenticationConverter(): Converter> { - return Converter> { jwt -> - - fun delegateMono(jwt: Jwt): ClassroomAuthentication { - val userCredentials = UserCredentials(jwt.claims) - return ClassroomAuthentication(userCredentials, jwt.tokenValue) - } - - Mono.just(jwt).map(::delegateMono) - } + return JwtToAuthenticationConverter() } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 158b407..f1e434b 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -37,4 +37,3 @@ spring: mapping-path: /rsocket transport: websocket ssl.enabled: true -