From db3d83b38dd61b90466a0721fa9104e742f3fb8b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 4 Oct 2013 20:28:30 +0200 Subject: Added Basic auth support to cHTTPRequest. --- source/HTTPServer/HTTPServer.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source/HTTPServer/HTTPServer.cpp') diff --git a/source/HTTPServer/HTTPServer.cpp b/source/HTTPServer/HTTPServer.cpp index 4102d1047..43bb751c4 100644 --- a/source/HTTPServer/HTTPServer.cpp +++ b/source/HTTPServer/HTTPServer.cpp @@ -73,6 +73,16 @@ class cDebugCallbacks : return; } + // Test the auth failure and success: + if (a_Request.GetURL() == "/auth") + { + if (!a_Request.HasAuth() || (a_Request.GetAuthUsername() != "a") || (a_Request.GetAuthPassword() != "b")) + { + a_Connection.SendNeedAuth("MCServer WebAdmin"); + return; + } + } + cHTTPResponse Resp; Resp.SetContentType("text/plain"); a_Connection.Send(Resp); -- cgit v1.2.3