Index: binary-improvements/7dtd-server-fixes/src/NetConnections/Servers/Web/PathHandler.cs
===================================================================
--- binary-improvements/7dtd-server-fixes/src/NetConnections/Servers/Web/PathHandler.cs	(revision 133)
+++ binary-improvements/7dtd-server-fixes/src/NetConnections/Servers/Web/PathHandler.cs	(revision 134)
@@ -6,5 +6,5 @@
 	public abstract class PathHandler
 	{
-		public abstract void HandleRequest(HttpListenerRequest req, HttpListenerResponse resp);
+		public abstract void HandleRequest(HttpListenerRequest req, HttpListenerResponse resp, HttpListenerBasicIdentity user);
 	}
 }
Index: binary-improvements/7dtd-server-fixes/src/NetConnections/Servers/Web/SimpleRedirectHandler.cs
===================================================================
--- binary-improvements/7dtd-server-fixes/src/NetConnections/Servers/Web/SimpleRedirectHandler.cs	(revision 133)
+++ binary-improvements/7dtd-server-fixes/src/NetConnections/Servers/Web/SimpleRedirectHandler.cs	(revision 134)
@@ -13,5 +13,5 @@
 		}
 
-		public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp)
+		public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, HttpListenerBasicIdentity user)
 		{
 			resp.Redirect (target);
Index: binary-improvements/7dtd-server-fixes/src/NetConnections/Servers/Web/StaticHandler.cs
===================================================================
--- binary-improvements/7dtd-server-fixes/src/NetConnections/Servers/Web/StaticHandler.cs	(revision 133)
+++ binary-improvements/7dtd-server-fixes/src/NetConnections/Servers/Web/StaticHandler.cs	(revision 134)
@@ -3,4 +3,5 @@
 using System.IO;
 using System.Net;
+using System.Threading;
 
 namespace AllocsFixes.NetConnections.Servers.Web
@@ -11,14 +12,16 @@
 		private string staticPart;
 		private bool cache;
+		private bool logMissingFiles;
 		private Dictionary<string, byte[]> fileCache = new Dictionary<string, byte[]> ();
 
-		public StaticHandler (string staticPart, string filePath, bool cache)
+		public StaticHandler (string staticPart, string filePath, bool cache, bool logMissingFiles)
 		{
 			this.staticPart = staticPart;
 			this.datapath = filePath;
 			this.cache = cache;
+			this.logMissingFiles = logMissingFiles;
 		}
 
-		public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp)
+		public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, HttpListenerBasicIdentity user)
 		{
 			try {
@@ -27,17 +30,26 @@
 				byte[] content;
 				if (cache) {
-					if (!fileCache.ContainsKey (fn)) {
-						if (!File.Exists (datapath + "/" + fn)) {
-							resp.StatusCode = (int)HttpStatusCode.NotFound;
-							return;
+					Monitor.Enter (fileCache);
+					try {
+						if (!fileCache.ContainsKey (fn)) {
+							if (!File.Exists (datapath + "/" + fn)) {
+								resp.StatusCode = (int)HttpStatusCode.NotFound;
+								if (logMissingFiles)
+									Log.Out ("Web:Static:FileNotFound: " + req.Url.AbsolutePath);
+								return;
+							}
+
+							fileCache.Add (fn, File.ReadAllBytes (datapath + "/" + fn));
 						}
 
-						fileCache.Add (fn, File.ReadAllBytes (datapath + "/" + fn));
+						content = fileCache [fn];
+					} finally {
+						Monitor.Exit (fileCache);
 					}
-
-					content = fileCache [fn];
 				} else {
 					if (!File.Exists (datapath + "/" + fn)) {
 						resp.StatusCode = (int)HttpStatusCode.NotFound;
+						if (logMissingFiles)
+							Log.Out ("Web:Static:FileNotFound: " + req.Url.AbsolutePath);
 						return;
 					}
Index: binary-improvements/7dtd-server-fixes/src/NetConnections/Servers/Web/Web.cs
===================================================================
--- binary-improvements/7dtd-server-fixes/src/NetConnections/Servers/Web/Web.cs	(revision 133)
+++ binary-improvements/7dtd-server-fixes/src/NetConnections/Servers/Web/Web.cs	(revision 134)
@@ -20,8 +20,9 @@
  
 				handlers.Add ("/index.", new SimpleRedirectHandler ("/static/index.html"));
-				handlers.Add ("/static/", new StaticHandler ("/static/", Application.dataPath + "/../webserver", true));
-				handlers.Add ("/map/", new StaticHandler ("/map/", StaticDirectories.GetSaveGameDir () + "/map", false));
+				handlers.Add ("/static/", new StaticHandler ("/static/", Application.dataPath + "/../webserver", true, true));
+				handlers.Add ("/map/", new StaticHandler ("/map/", StaticDirectories.GetSaveGameDir () + "/map", false, false));
 
 				_listener.Prefixes.Add (String.Format ("http://*:{0}/", port));
+				_listener.AuthenticationSchemes = AuthenticationSchemes.Basic;
 				_listener.Start ();
 
@@ -32,6 +33,6 @@
 							ThreadPool.QueueUserWorkItem ((c) =>
 							{
-								var ctx = c as HttpListenerContext;
-								HandleRequest (ctx.Request, ctx.Response);
+								HttpListenerContext ctx = c as HttpListenerContext;
+								HandleRequest (ctx);
 							}, _listener.GetContext ());
 						}
@@ -47,23 +48,30 @@
 		}
 
-		private void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp)
+		private void HandleRequest (HttpListenerContext ctx)
 		{
 			try {
-				resp.ProtocolVersion = new Version ("1.1");
+				ctx.Response.ProtocolVersion = new Version ("1.1");
 
-				if (req.Url.AbsolutePath.Length < 2) {
-					handlers ["/index."].HandleRequest (req, resp);
-					return;
-				} else {
-					foreach (KeyValuePair<string, PathHandler> kvp in handlers) {
-						if (req.Url.AbsolutePath.StartsWith (kvp.Key)) {
-							kvp.Value.HandleRequest (req, resp);
-							return;
+				HttpListenerBasicIdentity user;
+
+				if (Authorize (ctx, out user)) {
+					if (ctx.Request.Url.AbsolutePath.Length < 2) {
+						handlers ["/index."].HandleRequest (ctx.Request, ctx.Response, user);
+						return;
+					} else {
+						foreach (KeyValuePair<string, PathHandler> kvp in handlers) {
+							if (ctx.Request.Url.AbsolutePath.StartsWith (kvp.Key)) {
+								kvp.Value.HandleRequest (ctx.Request, ctx.Response, user);
+								return;
+							}
 						}
 					}
+
+					Log.Out ("Error in Web.HandleRequest(): No handler found for path \"" + ctx.Request.Url.AbsolutePath + "\"");
+					ctx.Response.StatusCode = (int)HttpStatusCode.NotFound;
+				} else {
+					ctx.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
+					ctx.Response.AddHeader("WWW-Authenticate", "Basic realm=\"\"");
 				}
-
-				Log.Out ("Error in Web.HandleRequest(): No handler found for path \"" + req.Url.AbsolutePath + "\"");
-				resp.StatusCode = (int)HttpStatusCode.NotFound;
 
 //				byte[] buf = Encoding.UTF8.GetBytes ("Hello World");
@@ -72,7 +80,19 @@
 //				resp.ContentEncoding = Encoding.UTF8;
 //				resp.OutputStream.Write (buf, 0, buf.Length);
-			} catch {
+			} catch (Exception e) {
+				Log.Out ("Error in Web.HandleRequest(): " + e);
 			} finally {
-				resp.Close ();
+				ctx.Response.Close ();
+			}
+		}
+
+		private bool Authorize (HttpListenerContext ctx, out HttpListenerBasicIdentity user)
+		{
+			try {
+				user = (HttpListenerBasicIdentity)ctx.User.Identity;
+				return user.Name.Equals ("admin") && user.Password.Equals (GamePrefs.GetString (EnumGamePrefs.ControlPanelPassword));
+			} catch (NullReferenceException) {
+				user = null;
+				return false;
 			}
 		}
