natario1
06/16/2021, 11:07 AMWWW-Authenticate on 401, so the Auth plugin is not working properly. I have tried with:
client.receivePipeline.intercept(HttpReceivePipeline.Before) { response ->
if (response.status == HttpStatusCode.Unauthorized && !response.headers.contains(HttpHeaders.WWWAuthenticate)) {
val headers = buildHeaders {
appendAll(response.headers)
append(HttpHeaders.WWWAuthenticate, "Bearer")
}
proceedWith(object : HttpResponse() {
override val headers get() = headers
// delegate all other properties to original response
})
} else {
proceed()
}
}
And I can see with the debugger that this is invoked before the header check in Ktor's Auth class. But still, the response passed to Auth does not include my header. It seems like the response passed to proceedWith() does not replace call.response, which is what Auth plugin reads. Any idea?Rustam Siniukov
06/16/2021, 11:28 AMreceivePipeline semantics is broken, because its context is HttpClientCall that has reference on response, that you can’t update. We will fix it in 2.0.0.
For now, you can only fix your backend or copy-paste Auth feature so that it doesn’t need WWW-Authenticate header.
Sorry =(Aleksei Tirman [JB]
06/16/2021, 11:39 AMnatario1
06/16/2021, 11:46 AMRustam Siniukov
06/16/2021, 11:54 AMnatario1
06/16/2021, 11:57 AMRustam Siniukov
06/16/2021, 3:02 PM