tweak logging in error case

This commit is contained in:
moehreag 2024-06-17 14:34:00 +02:00
parent 76daadaebe
commit bc8a864fc1

View file

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