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_PASSWORD = getEnv("PASSWORD", "example")
val POSTGRES_HOST = getEnv("HOST", "localhost") val POSTGRES_HOST = getEnv("HOST", "localhost")
val POSTGRES_PORT = getEnv("PORT", "5432") 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 { private fun getEnv(key: String, default: String): String {
return System.getenv("FROGMC_META_$key") ?: default return System.getenv("FROGMC_META_$key") ?: default
} }
} }

View file

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