Closed stanbar closed 6 years ago
Basic auth should respond Unauthorized
(with challenge header) not Forbidden
. Do you mean that you want to customize default behaviour or it simply doesn't respond with unauthorized?
You can use StatusPages plugin to respond appropriately to any failure state. It does also let respond to:
-exceptions- Configures response based on mapped exception classes.
-status- Configures response to status code value.
-statusFile- Configures standard file response from classpath.
In your case this you can do something like this:
install(StatusPages) {
status(HttpStatusCode.Unauthorized) {
call.respond(HttpStatusCode.Unauthorized, "Your Response Object")
}
}
Do not forget to pass in the same HttpStatusCode.Unauthorized
, cause otherwise you are turning this into a 200
.
Hello. How to handle failed authentication (for BasicAuthenication) ? my Pipeline looks like:
And I would like to be able to respond to failed authentication (case where basicAuthentication return null), something like
call.respond(HttpStatusCode.Forbidden,"Could not authenticate your credentials")