Skip to content

Commit 9a37638

Browse files
authored
Merge pull request #732 from modelix/feature/MODELIX-883_application-problem-json
feat(model-server): report errors as application/problem+json
2 parents 9c5f1f0 + 35500c1 commit 9a37638

File tree

8 files changed

+392
-119
lines changed

8 files changed

+392
-119
lines changed

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

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import io.ktor.server.auth.jwt.jwt
3434
import io.ktor.server.auth.parseAuthorizationHeader
3535
import io.ktor.server.auth.principal
3636
import io.ktor.server.plugins.forwardedheaders.XForwardedHeaders
37-
import io.ktor.server.plugins.statuspages.StatusPages
3837
import io.ktor.server.request.header
3938
import io.ktor.server.response.respond
4039
import io.ktor.server.response.respondText
@@ -85,28 +84,6 @@ fun Application.installAuthentication(unitTestMode: Boolean = false) {
8584
}
8685
}
8786
}
88-
install(StatusPages) {
89-
exception<Throwable> { call, cause ->
90-
when (cause) {
91-
is NoPermissionException -> call.respondText(
92-
text = cause.message ?: "",
93-
status = HttpStatusCode.Forbidden,
94-
)
95-
is NotLoggedInException -> call.respondText(
96-
text = cause.message ?: "",
97-
status = HttpStatusCode.Unauthorized,
98-
)
99-
else -> {
100-
val text = """
101-
|500: $cause
102-
|
103-
|${cause.stackTraceToString()}
104-
""".trimMargin()
105-
call.respondText(text = text, status = HttpStatusCode.InternalServerError)
106-
}
107-
}
108-
}
109-
}
11087
routing {
11188
authenticate(jwtAuth) {
11289
get("/user") {

0 commit comments

Comments
 (0)