Log a warning message on unauthorized http request

fixes #10388
This commit is contained in:
Michael Friedrich 2015-10-16 15:32:02 +02:00
parent a9f14f11e4
commit f51a76e13d
1 changed files with 5 additions and 1 deletions

View File

@ -143,13 +143,17 @@ void HttpServerConnection::ProcessMessageAsync(HttpRequest& request)
user.reset();
}
String requestUrl = request.RequestUrl->Format();
Log(LogInformation, "HttpServerConnection")
<< "Request: " << request.RequestMethod << " " << request.RequestUrl->Format()
<< "Request: " << request.RequestMethod << " " << requestUrl
<< " (" << (user ? user->GetName() : "<unauthenticated>") << ")";
HttpResponse response(m_Stream, request);
if (!user) {
Log(LogWarning, "HttpServerConnection")
<< "Unauthorized request: " << request.RequestMethod << " " << requestUrl;
response.SetStatus(401, "Unauthorized");
response.AddHeader("Content-Type", "text/html");
response.AddHeader("WWW-Authenticate", "Basic realm=\"Icinga 2\"");