Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade dependencies #563

Merged
merged 3 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions app/src/test/kotlin/cloud/fabX/fabXaccess/common/TestApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,6 @@ internal fun withTestApp(
val webApp = testSetup()

testApplication {
environment {
developmentMode = false
}
application {
webApp.moduleConfiguration(this)
}
Expand Down
32 changes: 16 additions & 16 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
[versions]
kotlin = "2.0.20"
arrow = "1.2.4"
kodein = "7.22.0"
ktor = "2.3.12"
micrometer = "1.13.4"
kotlin = "2.1.0"
arrow = "2.0.0"
kodein = "7.23.1"
ktor = "3.0.2"
micrometer = "1.14.1"
kotlinx-coroutines = "1.9.0"
kotlinx-datetime = "0.6.1"
kotlinx-serialization-json = "1.7.3"
exposed = "0.55.0"
hikari = "6.0.0"
exposed = "0.57.0"
hikari = "6.2.1"
postgresql = "42.7.4"
liquibase = "4.29.2"
liquibase-slf4j = "5.0.0"
webauthn4j = "0.26.0.RELEASE"
scrimage = "4.2.0"
logback = "1.5.8"
liquibase = "4.30.0"
liquibase-slf4j = "5.1.0"
webauthn4j = "0.28.3.RELEASE"
scrimage = "4.3.0"
logback = "1.5.12"
slf4j = "2.0.16"

junit = "5.11.1"
junit = "5.11.3"
assertk = "0.28.1"
mockito-kotlin = "5.4.0"
mockito-junit5 = "5.14.0"
mockito-junit5 = "5.14.2"
kotlin-wiremock = "2.1.1"
testcontainers = "1.20.2"
testcontainers = "1.20.4"

[libraries]
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
Expand Down Expand Up @@ -78,6 +78,6 @@ testcontainers-postgres = { module = "org.testcontainers:postgresql", version.re
[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
shadow = { id = "com.github.johnrengelman.shadow", version = "8.1.1" }
shadow = { id = "com.gradleup.shadow", version = "8.3.5" }
versions = { id = "com.github.ben-manes.versions", version = "0.51.0" }
node = { id = "com.github.node-gradle.node", version = "7.1.0" }
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
22 changes: 13 additions & 9 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -83,7 +85,9 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -144,15 +148,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -201,11 +205,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
22 changes: 12 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 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.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +59,11 @@ 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.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
25 changes: 7 additions & 18 deletions web/src/main/kotlin/cloud/fabX/fabXaccess/WebApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,18 @@ import io.ktor.http.HttpMethod
import io.ktor.http.HttpStatusCode
import io.ktor.serialization.kotlinx.json.json
import io.ktor.server.application.Application
import io.ktor.server.application.call
import io.ktor.server.application.install
import io.ktor.server.auth.Authentication
import io.ktor.server.auth.authenticate
import io.ktor.server.auth.basic
import io.ktor.server.auth.jwt.jwt
import io.ktor.server.engine.applicationEngineEnvironment
import io.ktor.server.engine.connector
import io.ktor.server.engine.embeddedServer
import io.ktor.server.http.content.angular
import io.ktor.server.http.content.singlePageApplication
import io.ktor.server.metrics.micrometer.MicrometerMetrics
import io.ktor.server.netty.Netty
import io.ktor.server.plugins.BadRequestException
import io.ktor.server.plugins.callloging.CallLogging
import io.ktor.server.plugins.calllogging.CallLogging
import io.ktor.server.plugins.contentnegotiation.ContentNegotiation
import io.ktor.server.plugins.forwardedheaders.XForwardedHeaders
import io.ktor.server.plugins.httpsredirect.HttpsRedirect
Expand All @@ -55,7 +52,7 @@ import io.ktor.server.websocket.WebSockets
import io.ktor.server.websocket.pingPeriod
import io.ktor.server.websocket.timeout
import io.micrometer.prometheusmetrics.PrometheusMeterRegistry
import java.time.Duration
import kotlin.time.Duration
import kotlinx.serialization.json.Json
import org.slf4j.MDC
import org.slf4j.event.Level
Expand Down Expand Up @@ -176,8 +173,8 @@ class WebApp(
}

install(WebSockets) {
pingPeriod = Duration.ofSeconds(10)
timeout = Duration.ofSeconds(10)
pingPeriod = Duration.parse("10s")
timeout = Duration.parse("10s")
maxFrameSize = Long.MAX_VALUE
masking = false
}
Expand Down Expand Up @@ -242,16 +239,8 @@ class WebApp(
fun start() {
log.info("starting WebApp...")

embeddedServer(Netty, environment = applicationEngineEnvironment {

module {
moduleConfiguration()
}

connector {
port = publicPort
}

}).start(wait = true)
embeddedServer(Netty, port = publicPort) {
moduleConfiguration()
}.start(wait = true)
}
}
11 changes: 5 additions & 6 deletions web/src/main/kotlin/cloud/fabX/fabXaccess/common/rest/Auth.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ import cloud.fabX.fabXaccess.user.model.Member
import cloud.fabX.fabXaccess.user.rest.ErrorPrincipal
import cloud.fabX.fabXaccess.user.rest.UserPrincipal
import io.ktor.server.application.ApplicationCall
import io.ktor.server.application.call
import io.ktor.server.auth.principal
import io.ktor.server.routing.RoutingContext
import io.ktor.server.websocket.WebSocketServerSession
import io.ktor.util.pipeline.PipelineContext

internal fun PipelineContext<*, ApplicationCall>.readAdminAuthentication(): Either<Error, Admin> {
internal fun RoutingContext.readAdminAuthentication(): Either<Error, Admin> {
call.principal<UserPrincipal>()?.let { userPrincipal ->
return userPrincipal.right()
.flatMap { it.asAdmin() }
Expand All @@ -29,7 +28,7 @@ internal fun PipelineContext<*, ApplicationCall>.readAdminAuthentication(): Eith
return Error.NotAuthenticated("Required authentication not found.").left()
}

internal fun PipelineContext<*, ApplicationCall>.readInstructorAuthentication(): Either<Error, Instructor> {
internal fun RoutingContext.readInstructorAuthentication(): Either<Error, Instructor> {
call.principal<UserPrincipal>()?.let { userPrincipal ->
return userPrincipal.right()
.flatMap { it.asInstructor() }
Expand All @@ -40,7 +39,7 @@ internal fun PipelineContext<*, ApplicationCall>.readInstructorAuthentication():
return Error.NotAuthenticated("Required authentication not found.").left()
}

internal fun PipelineContext<*, ApplicationCall>.readMemberAuthentication(): Either<Error, Member> {
internal fun RoutingContext.readMemberAuthentication(): Either<Error, Member> {
call.principal<UserPrincipal>()?.let { userPrincipal ->
return userPrincipal.right()
.map { it.asMember() }
Expand All @@ -51,7 +50,7 @@ internal fun PipelineContext<*, ApplicationCall>.readMemberAuthentication(): Eit
return Error.NotAuthenticated("Required authentication not found.").left()
}

internal fun PipelineContext<*, ApplicationCall>.readDeviceAuthentication(): Either<Error, DeviceActor> {
internal fun RoutingContext.readDeviceAuthentication(): Either<Error, DeviceActor> {
return call.readDeviceAuthentication()
}

Expand Down
6 changes: 2 additions & 4 deletions web/src/main/kotlin/cloud/fabX/fabXaccess/common/rest/Body.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package cloud.fabX.fabXaccess.common.rest

import io.ktor.http.HttpStatusCode
import io.ktor.server.application.ApplicationCall
import io.ktor.server.application.call
import io.ktor.server.request.ContentTransformationException
import io.ktor.server.request.receive
import io.ktor.server.response.respond
import io.ktor.util.pipeline.PipelineContext
import io.ktor.server.routing.RoutingContext

internal suspend inline fun <reified T : Any> PipelineContext<*, ApplicationCall>.readBody(): T? {
internal suspend inline fun <reified T : Any> RoutingContext.readBody(): T? {
return try {
call.receive()
} catch (e: ContentTransformationException) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package cloud.fabX.fabXaccess.common.rest

import io.ktor.server.auth.Principal

class MetricsPrincipal : Principal
class MetricsPrincipal
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package cloud.fabX.fabXaccess.common.rest

import io.ktor.http.HttpStatusCode
import io.ktor.server.application.ApplicationCall
import io.ktor.server.application.call
import io.ktor.server.response.respond
import io.ktor.util.pipeline.PipelineContext
import io.ktor.server.routing.RoutingContext
import java.util.UUID

suspend inline fun PipelineContext<*, ApplicationCall>.readUUIDParameter(name: String): UUID? {
suspend inline fun RoutingContext.readUUIDParameter(name: String): UUID? {
call.parameters[name]?.let {
try {
UUID.fromString(it)
Expand All @@ -22,7 +20,7 @@ suspend inline fun PipelineContext<*, ApplicationCall>.readUUIDParameter(name: S
return null
}

suspend inline fun PipelineContext<*, ApplicationCall>.readIntParameter(name: String): Int? {
suspend inline fun RoutingContext.readIntParameter(name: String): Int? {
call.parameters[name]?.toIntOrNull()?.let {
return it
}
Expand All @@ -31,7 +29,7 @@ suspend inline fun PipelineContext<*, ApplicationCall>.readIntParameter(name: St
return null
}

suspend inline fun PipelineContext<*, ApplicationCall>.readStringParameter(name: String): String? {
suspend inline fun RoutingContext.readStringParameter(name: String): String? {
call.parameters[name]?.let {
return it
}
Expand All @@ -40,7 +38,7 @@ suspend inline fun PipelineContext<*, ApplicationCall>.readStringParameter(name:
return null
}

suspend inline fun PipelineContext<*, ApplicationCall>.readHexStringParameter(name: String): ByteArray? {
suspend inline fun RoutingContext.readHexStringParameter(name: String): ByteArray? {
call.parameters[name]?.let {
try {
check(it.length % 2 == 0) { "Must have an even length" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import cloud.fabX.fabXaccess.common.model.Error
import cloud.fabX.fabXaccess.user.model.Admin
import cloud.fabX.fabXaccess.user.model.Instructor
import cloud.fabX.fabXaccess.user.model.Member
import io.ktor.server.application.ApplicationCall
import io.ktor.server.application.call
import io.ktor.util.pipeline.PipelineContext
import io.ktor.server.routing.RoutingContext


internal suspend inline fun <reified T : Any> PipelineContext<*, ApplicationCall>.withAdminAuthRespond(
internal suspend inline fun <reified T : Any> RoutingContext.withAdminAuthRespond(
function: (Admin) -> Either<Error, T>
) {
return call.respondWithErrorHandler(
Expand All @@ -23,7 +21,7 @@ internal suspend inline fun <reified T : Any> PipelineContext<*, ApplicationCall
)
}

internal suspend inline fun <reified T : Any> PipelineContext<*, ApplicationCall>.withMemberAuthRespond(
internal suspend inline fun <reified T : Any> RoutingContext.withMemberAuthRespond(
function: (Member) -> Either<Error, T>
) {
return call.respondWithErrorHandler(
Expand All @@ -34,7 +32,7 @@ internal suspend inline fun <reified T : Any> PipelineContext<*, ApplicationCall
)
}

internal suspend inline fun <reified T : Any> PipelineContext<*, ApplicationCall>.withAdminOrMemberAuthRespond(
internal suspend inline fun <reified T : Any> RoutingContext.withAdminOrMemberAuthRespond(
asAdminFunction: (Admin) -> Either<Error, T>,
asMemberFunction: (Member) -> Either<Error, T>
) {
Expand All @@ -59,7 +57,7 @@ internal suspend inline fun <reified T : Any> PipelineContext<*, ApplicationCall
)
}

internal suspend inline fun <reified T : Any> PipelineContext<*, ApplicationCall>.withInstructorAuthRespond(
internal suspend inline fun <reified T : Any> RoutingContext.withInstructorAuthRespond(
function: (Instructor) -> Either<Error, T>
) {
return call.respondWithErrorHandler(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package cloud.fabX.fabXaccess.common.rest

interface Principal
Loading
Loading