Skip to content

Commit 94a2a6a

Browse files
committed
fix(authorization): stacktrace of exceptions wasn't visible anywhere
1 parent ffb30e5 commit 94a2a6a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

authorization/src/main/kotlin/org/modelix/authorization/AuthorizationPlugin.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import io.ktor.server.auth.parseAuthorizationHeader
2727
import io.ktor.server.auth.principal
2828
import io.ktor.server.plugins.forwardedheaders.XForwardedHeaders
2929
import io.ktor.server.plugins.statuspages.StatusPages
30+
import io.ktor.server.request.uri
3031
import io.ktor.server.response.respond
3132
import io.ktor.server.response.respondText
3233
import io.ktor.server.routing.Route
@@ -141,6 +142,7 @@ object ModelixAuthorization : BaseRouteScopedPlugin<IModelixAuthorizationConfig,
141142
call.respondText(text = "403: ${cause.message}", status = HttpStatusCode.Forbidden)
142143
}
143144
exception<Throwable> { call, cause ->
145+
LOG.error(cause) { call.request.uri }
144146
call.respondText(text = "500: $cause", status = HttpStatusCode.InternalServerError)
145147
}
146148
}
@@ -246,7 +248,7 @@ internal fun ModelixAuthorizationConfig.getVerifier() = object : JWTVerifier {
246248
if (jwt == null) {
247249
throw JWTVerificationException("No JWT provided.")
248250
}
249-
return this@getVerifier.nullIfInvalid(jwt)?.also { println("Valid token: ${jwt.token}") } ?: throw JWTVerificationException("JWT invalid.")
251+
return this@getVerifier.nullIfInvalid(jwt) ?: throw JWTVerificationException("JWT invalid.")
250252
} catch (ex: BadJWTException) {
251253
throw JWTVerificationException("Invalid token: ${jwt?.token}", ex)
252254
}

0 commit comments

Comments
 (0)