Hey. I am doing a custom AuthenticationProvider an...
# ktor
a
Hey. I am doing a custom AuthenticationProvider and intercepting calls (both RequestAuthentication and CheckAuthentication) and returning av 401 when my custom checks fail. But it still reaches the endpoint code even though authentication fails. Is there some way to stop further processing? I have tried (a wild guess) to
Copy code
return@intercept finish()
but it still continues processing.... Any idea?
Found the answer... Had to issue a challenge... Not entirely sure why (the call chain can be quite long), but at least it works. ­čÖé
Copy code
context.challenge("pbAuth", AuthenticationFailedCause.InvalidCredentials) {
    call.respond(UnauthorizedResponse())
    if (!it.completed && call.response.status() != null) {
        it.complete()
    }
}