Fix: Inform client about authentication scheme if unauthorized

This commit is contained in:
Lennart
2023-09-07 18:51:13 +02:00
parent e7d73e180a
commit 8ad6fa42b6

View File

@@ -23,6 +23,11 @@ impl actix_web::error::ResponseError for Error {
} }
fn error_response(&self) -> HttpResponse { fn error_response(&self) -> HttpResponse {
HttpResponse::build(self.status_code()).body(self.to_string()) match self {
Error::Unauthorized => HttpResponse::build(self.status_code())
.append_header(("WWW-Authenticate", "Basic"))
.body(self.to_string()),
_ => HttpResponse::build(self.status_code()).body(self.to_string()),
}
} }
} }