diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index 04b8501223..831707387d 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs @@ -421,45 +421,44 @@ namespace OpenSim.Framework.UserManagement if (keysvals.ContainsKey("show_login_form")) { - if ((string)keysvals["show_login_form"] == "TRUE") + + UserProfileData user = GetTheUser(firstname, lastname); + bool goodweblogin = false; + + if (user != null) + goodweblogin = AuthenticateUser(user, password); + + if (goodweblogin) { + LLUUID webloginkey = LLUUID.Random(); + m_userManager.StoreWebLoginKey(user.UUID, webloginkey); + statuscode = 301; + + string redirectURL = "about:blank?redirect-http-hack=" + System.Web.HttpUtility.UrlEncode("secondlife:///app/login?first_name=" + firstname + "&last_name=" + + lastname + + "&location=" + location + "&grid=Other&web_login_key=" + webloginkey.ToString()); + //MainLog.Instance.Verbose("WEB", "R:" + redirectURL); returnactions["int_response_code"] = statuscode; - returnactions["str_response_string"] = loginform; + returnactions["str_redirect_location"] = redirectURL; + returnactions["str_response_string"] = "GoodLogin"; } else { - UserProfileData user = GetTheUser(firstname, lastname); - bool goodweblogin = false; + errormessages = "The Username and password supplied did not match our records. Check your caps lock and try again"; - if (user != null) - goodweblogin = AuthenticateUser(user, password); - - if (goodweblogin) - { - LLUUID webloginkey = LLUUID.Random(); - m_userManager.StoreWebLoginKey(user.UUID, webloginkey); - statuscode = 301; - - string redirectURL = "secondlife:///app/login?first_name=" + firstname + "&last_name=" + - lastname + - "&location=" + location + "&grid=Other&web_login_key=" + webloginkey.ToString(); - - returnactions["int_response_code"] = statuscode; - returnactions["str_redirect_location"] = redirectURL; - returnactions["str_response_string"] = "GoodLogin"; - } - else - { - errormessages = "The Username and password supplied did not match our records. Check your caps lock and try again"; - - loginform = GetLoginForm(firstname, lastname, location, region, grid, channel, version, lang, password, errormessages); - returnactions["int_response_code"] = statuscode; - returnactions["str_response_string"] = loginform; - - } + loginform = GetLoginForm(firstname, lastname, location, region, grid, channel, version, lang, password, errormessages); + returnactions["int_response_code"] = statuscode; + returnactions["str_response_string"] = loginform; } + + + } + else + { + returnactions["int_response_code"] = statuscode; + returnactions["str_response_string"] = loginform; } return returnactions; @@ -511,7 +510,7 @@ namespace OpenSim.Framework.UserManagement responseString = responseString + "
"; responseString = responseString + "
"; - responseString = responseString + "
"; + responseString = responseString + ""; responseString = responseString + "
[$errors]
"; responseString = responseString + "
"; diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs index 3ca4187831..78554c386e 100644 --- a/OpenSim/Framework/Servers/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/BaseHttpServer.cs @@ -381,6 +381,8 @@ namespace OpenSim.Framework.Servers string responseString = String.Empty; Hashtable keysvals = new Hashtable(); + Hashtable headervals = new Hashtable(); + string host = ""; string[] querystringkeys = request.QueryString.AllKeys; string[] rHeaders = request.Headers.AllKeys; @@ -391,12 +393,23 @@ namespace OpenSim.Framework.Servers keysvals.Add(queryname, request.QueryString[queryname]); } - + + foreach (string headername in rHeaders) + { + //MainLog.Instance.Warn("HEADER", headername + "=" + request.Headers[headername]); + headervals[headername] = request.Headers[headername]; + } + + if (headervals.Contains("Host")) + { + host = (string)headervals["Host"]; + } + if (keysvals.Contains("method")) { - MainLog.Instance.Warn("HTTP", "Contains Method"); + //MainLog.Instance.Warn("HTTP", "Contains Method"); string method = (string) keysvals["method"]; - MainLog.Instance.Warn("HTTP", requestBody); + //MainLog.Instance.Warn("HTTP", requestBody); GenericHTTPMethod requestprocessor; bool foundHandler = TryGetHTTPHandler(method, out requestprocessor); if (foundHandler) @@ -409,14 +422,14 @@ namespace OpenSim.Framework.Servers } else { - MainLog.Instance.Warn("HTTP", "Handler Not Found"); - SendHTML404(response); + //MainLog.Instance.Warn("HTTP", "Handler Not Found"); + SendHTML404(response, host); } } else { - MainLog.Instance.Warn("HTTP", "No Method specified"); - SendHTML404(response); + //MainLog.Instance.Warn("HTTP", "No Method specified"); + SendHTML404(response, host); } } @@ -457,13 +470,13 @@ namespace OpenSim.Framework.Servers } - public void SendHTML404(HttpListenerResponse response) + public void SendHTML404(HttpListenerResponse response, string host) { // I know this statuscode is dumb, but the client doesn't respond to 404s and 500s response.StatusCode = 200; response.AddHeader("Content-type", "text/html"); - string responseString = GetHTTP404(); + string responseString = GetHTTP404(host); byte[] buffer = Encoding.UTF8.GetBytes(responseString); response.SendChunked = false; @@ -558,11 +571,11 @@ namespace OpenSim.Framework.Servers m_HTTPHandlers.Remove(GetHandlerKey(httpMethod, path)); } - public string GetHTTP404() + public string GetHTTP404(string host) { string file = Path.Combine(Util.configDir(), "http_404.html"); if (!File.Exists(file)) - return getDefaultHTTP404(); + return getDefaultHTTP404(host); StreamReader sr = File.OpenText(file); string result = sr.ReadToEnd(); @@ -583,9 +596,9 @@ namespace OpenSim.Framework.Servers } // Fallback HTTP responses in case the HTTP error response files don't exist - private string getDefaultHTTP404() + private string getDefaultHTTP404(string host) { - return "404 Page not found

Ooops!

The page you requested has been obsconded with by knomes. Find hippos quick!

"; + return "404 Page not found

Ooops!

The page you requested has been obsconded with by knomes. Find hippos quick!

If you are trying to log-in, your link parameters should have: "-loginpage http://" + host + "/?method=login -loginuri http://" + host + "/" in your link

"; } private string getDefaultHTTP500() diff --git a/bin/http_loginform.html.example b/bin/http_loginform.html.example index 16655dedf9..41a1083ac4 100644 --- a/bin/http_loginform.html.example +++ b/bin/http_loginform.html.example @@ -8,7 +8,7 @@
- +
[$errors]