tweak logging in error case
This commit is contained in:
parent
76daadaebe
commit
bc8a864fc1
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue