tweak logging for debugging purposes

This commit is contained in:
moehreag 2024-06-17 15:27:27 +02:00
parent bc8a864fc1
commit e0e35eb97c
2 changed files with 6 additions and 6 deletions

View file

@ -6,9 +6,9 @@ object Config {
val POSTGRES_PASSWORD = getEnv("PASSWORD", "example")
val POSTGRES_HOST = getEnv("HOST", "localhost")
val POSTGRES_PORT = getEnv("PORT", "5432")
val UPLOAD_SECRET = getEnv("UPLOAD_SECRET", "").toByteArray()
val UPLOAD_SECRET = getEnv("UPLOAD_SECRET", "")
private fun getEnv(key: String, default: String): String {
return System.getenv("FROGMC_META_$key") ?: default
}
}
}

View file

@ -12,15 +12,15 @@ val authPlugin = createRouteScopedPlugin("auth") {
val authorization = it.request.headers["Authorization"]
if (authorization.isNullOrEmpty() || !MessageDigest.isEqual(
authorization.toByteArray(),
Config.UPLOAD_SECRET
Config.UPLOAD_SECRET.toByteArray()
)
) {
logger.info(
"Authentication Failed: provided: ${
authorization?.toByteArray().contentToString()
}; expected: ${Config.UPLOAD_SECRET.contentToString()}"
authorization
}; expected: ${Config.UPLOAD_SECRET}"
)
it.respond(HttpStatusCode.Unauthorized)
}
}
}
}