* This may be broken.. it hasn't been tested, however I wanted to get the last database changes in before sdauge changes them significantly.
parent
7ba9c13fa8
commit
49fe4eb3cd
|
@ -29,6 +29,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using libsecondlife;
|
||||
using libsecondlife.StructuredData;
|
||||
|
@ -79,7 +80,7 @@ namespace OpenSim.Framework.UserManagement
|
|||
Hashtable requestData = (Hashtable) request.Params[0];
|
||||
|
||||
bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") &&
|
||||
requestData.Contains("passwd"));
|
||||
(requestData.Contains("passwd") || requestData.Contains("web_login_key")));
|
||||
bool GoodLogin = false;
|
||||
|
||||
UserProfileData userProfile;
|
||||
|
@ -89,7 +90,8 @@ namespace OpenSim.Framework.UserManagement
|
|||
{
|
||||
string firstname = (string) requestData["first"];
|
||||
string lastname = (string) requestData["last"];
|
||||
string passwd = (string) requestData["passwd"];
|
||||
|
||||
|
||||
|
||||
userProfile = GetTheUser(firstname, lastname);
|
||||
if (userProfile == null)
|
||||
|
@ -100,9 +102,30 @@ namespace OpenSim.Framework.UserManagement
|
|||
|
||||
return logResponse.CreateLoginFailedResponse();
|
||||
}
|
||||
|
||||
if (requestData.Contains("passwd"))
|
||||
{
|
||||
string passwd = (string)requestData["passwd"];
|
||||
GoodLogin = AuthenticateUser(userProfile, passwd);
|
||||
}
|
||||
else if (requestData.Contains("web_login_key"))
|
||||
{
|
||||
LLUUID webloginkey = null;
|
||||
try
|
||||
{
|
||||
webloginkey = new LLUUID((string)requestData["web_login_key"]);
|
||||
}
|
||||
catch (System.Exception)
|
||||
{
|
||||
return logResponse.CreateFailedResponse();
|
||||
}
|
||||
GoodLogin = AuthenticateUser(userProfile, webloginkey);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return logResponse.CreateFailedResponse();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return logResponse.CreateGridErrorResponse();
|
||||
|
@ -334,6 +357,105 @@ namespace OpenSim.Framework.UserManagement
|
|||
{
|
||||
}
|
||||
|
||||
public Hashtable ProcessHTMLLogin(Hashtable keysvals)
|
||||
{
|
||||
Hashtable returnactions = new Hashtable();
|
||||
int statuscode = 200;
|
||||
|
||||
returnactions["int_response_code"] = statuscode;
|
||||
returnactions["str_response_string"] = GetDefaultLoginForm();
|
||||
|
||||
if (keysvals.ContainsKey("show_login_form"))
|
||||
{
|
||||
if ((string)keysvals["show_login_form"] == "TRUE")
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return returnactions;
|
||||
|
||||
}
|
||||
|
||||
public string GetLoginForm()
|
||||
{
|
||||
string file = Path.Combine(Util.configDir(), "http_loginform.html");
|
||||
if (!File.Exists(file))
|
||||
return GetDefaultLoginForm();
|
||||
|
||||
StreamReader sr = File.OpenText(file);
|
||||
string result = sr.ReadToEnd();
|
||||
sr.Close();
|
||||
return result;
|
||||
}
|
||||
|
||||
public string GetDefaultLoginForm()
|
||||
{
|
||||
string responseString =
|
||||
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
|
||||
responseString = responseString + "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
|
||||
responseString = responseString + "<head>";
|
||||
responseString = responseString +
|
||||
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
|
||||
responseString = responseString + "<meta http-equiv=\"cache-control\" content=\"no-cache\">";
|
||||
responseString = responseString + "<meta http-equiv=\"Pragma\" content=\"no-cache\">";
|
||||
responseString = responseString + "<title>Second Life Login</title>";
|
||||
responseString = responseString + "<body>";
|
||||
responseString = responseString + "<div id=\"login_box\">";
|
||||
|
||||
responseString = responseString + "<form action=\"/\" method=\"GET\" id=\"login-form\">";
|
||||
|
||||
responseString = responseString + "<div id=\"message\">[$errors]</div>";
|
||||
responseString = responseString + "<fieldset id=\"firstname\">";
|
||||
responseString = responseString + "<legend>First Name:</legend>";
|
||||
responseString = responseString + "<input type=\"text\" id=\"firstname_input\" size=\"15\" maxlength=\"100\" name=\"username\" value=\"[$firstname]\" />";
|
||||
responseString = responseString + "</fieldset>";
|
||||
responseString = responseString + "<fieldset id=\"lastname\">";
|
||||
responseString = responseString + "<legend>Last Name:</legend>";
|
||||
responseString = responseString + "<input type=\"text\" size=\"15\" maxlength=\"100\" name=\"lastname\" value=\"[$lastname]\" />";
|
||||
responseString = responseString + "</fieldset>";
|
||||
responseString = responseString + "<fieldset id=\"password\">";
|
||||
responseString = responseString + "<legend>Password:</legend>";
|
||||
responseString = responseString + "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
|
||||
responseString = responseString + "<tr>";
|
||||
responseString = responseString + "<td colspan=\"2\"><input type=\"password\" size=\"15\" maxlength=\"100\" name=\"password\" value=\"[$password]\" /></td>";
|
||||
responseString = responseString + "</tr>";
|
||||
responseString = responseString + "<tr>";
|
||||
responseString = responseString + "<td valign=\"middle\"><input type=\"checkbox\" name=\"remember_password\" id=\"remember_password\" [$remember_password] style=\"margin-left:0px;\"/></td>";
|
||||
responseString = responseString + "<td><label for=\"remember_password\">Remember password</label></td>";
|
||||
responseString = responseString + "</tr>";
|
||||
responseString = responseString + "</table>";
|
||||
responseString = responseString + "</fieldset>";
|
||||
responseString = responseString + "<input type=\"hidden\" name=\"show_login_form\" value=\"FALSE\" />";
|
||||
responseString = responseString + "<input type=\"hidden\" name=\"method\" value=\"login\" />";
|
||||
responseString = responseString + "<input type=\"hidden\" id=\"grid\" name=\"grid\" value=\"[$grid]\" />";
|
||||
responseString = responseString + "<div id=\"submitbtn\">";
|
||||
responseString = responseString + "<input class=\"input_over\" type=\"submit\" value=\"Connect\" />";
|
||||
responseString = responseString + "</div>";
|
||||
responseString = responseString + "<div id=\"connecting\" style=\"visibility:hidden\"> Connecting...</div>";
|
||||
|
||||
responseString = responseString + "<div id=\"helplinks\">";
|
||||
responseString = responseString + "<a href=\"http://www.secondlife.com/join/index.php\" target=\"_blank\">Create new account</a> | ";
|
||||
responseString = responseString + "<a href=\"http://www.secondlife.com/account/request.php\" target=\"_blank\">Forgot password?</a>";
|
||||
responseString = responseString + "</div>";
|
||||
|
||||
responseString = responseString + "<div id=\"channelinfo\"> [$clientchannelinfo] | [$clientversion]=[$clientlanguage]</div>";
|
||||
responseString = responseString + "</form>";
|
||||
responseString = responseString + "<script language=\"JavaScript\">";
|
||||
responseString = responseString + "document.getElementById('firstname_input').focus();";
|
||||
responseString = responseString + "</script>";
|
||||
responseString = responseString + "</div>";
|
||||
responseString = responseString + "</div>";
|
||||
responseString = responseString + "</body>";
|
||||
responseString = responseString + "</html>";
|
||||
return responseString;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves a target agent to the database
|
||||
/// </summary>
|
||||
|
@ -353,14 +475,33 @@ namespace OpenSim.Framework.UserManagement
|
|||
/// <returns>Authenticated?</returns>
|
||||
public virtual bool AuthenticateUser(UserProfileData profile, string password)
|
||||
{
|
||||
bool passwordSuccess = false;
|
||||
MainLog.Instance.Verbose(
|
||||
"LOGIN", "Authenticating {0} {1} ({2})", profile.username, profile.surname, profile.UUID);
|
||||
|
||||
// Web Login method seems to also occasionally send the hashed password itself
|
||||
|
||||
|
||||
password = password.Remove(0, 3); //remove $1$
|
||||
|
||||
string s = Util.Md5Hash(password + ":" + profile.passwordSalt);
|
||||
|
||||
return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase);
|
||||
passwordSuccess = (profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase)
|
||||
|| profile.passwordHash.Equals(password.ToString(),StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
return passwordSuccess;
|
||||
}
|
||||
|
||||
public virtual bool AuthenticateUser(UserProfileData profile, LLUUID webloginkey)
|
||||
{
|
||||
bool passwordSuccess = false;
|
||||
MainLog.Instance.Verbose(
|
||||
"LOGIN", "Authenticating {0} {1} ({2})", profile.username, profile.surname, profile.UUID);
|
||||
|
||||
// Match web login key unless it's the default weblogin key LLUUID.Zero
|
||||
passwordSuccess = ((profile.webLoginKey==webloginkey) && profile.webLoginKey != LLUUID.Zero);
|
||||
|
||||
return passwordSuccess;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -222,6 +222,23 @@ namespace OpenSim.Framework.UserManagement
|
|||
|
||||
}
|
||||
|
||||
public void StoreWebLoginKey(LLUUID agentID, LLUUID webLoginKey)
|
||||
{
|
||||
|
||||
foreach (KeyValuePair<string, IUserData> plugin in _plugins)
|
||||
{
|
||||
try
|
||||
{
|
||||
plugin.Value.StoreWebLoginKey(agentID, webLoginKey);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MainLog.Instance.Verbose("USERSTORAGE",
|
||||
"Unable to Store WebLoginKey via " + plugin.Key + "(" + e.ToString() + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms)
|
||||
{
|
||||
foreach (KeyValuePair<string, IUserData> plugin in _plugins)
|
||||
|
|
|
@ -132,7 +132,13 @@ namespace OpenSim.Framework.Data.DB4o
|
|||
return null;
|
||||
}
|
||||
}
|
||||
public void StoreWebLoginKey(LLUUID AgentID, LLUUID WebLoginKey)
|
||||
{
|
||||
UserProfileData user = GetUserByUUID(AgentID);
|
||||
user.webLoginKey = WebLoginKey;
|
||||
UpdateUserProfile(user);
|
||||
|
||||
}
|
||||
#region User Friends List Data
|
||||
|
||||
public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms)
|
||||
|
|
|
@ -297,7 +297,13 @@ namespace OpenSim.Framework.Data.MSSQL
|
|||
return null;
|
||||
}
|
||||
}
|
||||
public void StoreWebLoginKey(LLUUID AgentID, LLUUID WebLoginKey)
|
||||
{
|
||||
UserProfileData user = GetUserByUUID(AgentID);
|
||||
user.webLoginKey = WebLoginKey;
|
||||
UpdateUserProfile(user);
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Creates a new users profile
|
||||
/// </summary>
|
||||
|
@ -358,7 +364,8 @@ namespace OpenSim.Framework.Data.MSSQL
|
|||
"profileAboutText = @profileAboutText," +
|
||||
"profileFirstText = @profileFirstText," +
|
||||
"profileImage = @profileImage," +
|
||||
"profileFirstImage = @profileFirstImage where " +
|
||||
"profileFirstImage = @profileFirstImage, " +
|
||||
"webLoginKey = @webLoginKey where " +
|
||||
"UUID = @keyUUUID;", database.getConnection());
|
||||
SqlParameter param1 = new SqlParameter("@uuid", user.UUID.ToString());
|
||||
SqlParameter param2 = new SqlParameter("@username", user.username);
|
||||
|
@ -383,6 +390,7 @@ namespace OpenSim.Framework.Data.MSSQL
|
|||
SqlParameter param21 = new SqlParameter("@profileImage", LLUUID.Zero.ToString());
|
||||
SqlParameter param22 = new SqlParameter("@profileFirstImage", LLUUID.Zero.ToString());
|
||||
SqlParameter param23 = new SqlParameter("@keyUUUID", user.UUID.ToString());
|
||||
SqlParameter param24 = new SqlParameter("@webLoginKey", user.webLoginKey.UUID.ToString());
|
||||
command.Parameters.Add(param1);
|
||||
command.Parameters.Add(param2);
|
||||
command.Parameters.Add(param3);
|
||||
|
@ -406,6 +414,7 @@ namespace OpenSim.Framework.Data.MSSQL
|
|||
command.Parameters.Add(param21);
|
||||
command.Parameters.Add(param22);
|
||||
command.Parameters.Add(param23);
|
||||
command.Parameters.Add(param24);
|
||||
try
|
||||
{
|
||||
int affected = command.ExecuteNonQuery();
|
||||
|
|
|
@ -466,6 +466,39 @@ namespace OpenSim.Framework.Data.MySQL
|
|||
{
|
||||
UserProfileData profile = GetUserByName(user, last);
|
||||
return GetAgentByUUID(profile.UUID);
|
||||
}
|
||||
|
||||
public void StoreWebLoginKey(LLUUID AgentID, LLUUID WebLoginKey)
|
||||
{
|
||||
|
||||
Dictionary<string, string> param = new Dictionary<string, string>();
|
||||
param["?UUID"] = AgentID.UUID.ToString();
|
||||
param["?webLoginKey"] = WebLoginKey.UUID.ToString();
|
||||
|
||||
try
|
||||
{
|
||||
lock (database)
|
||||
{
|
||||
IDbCommand updater =
|
||||
database.Query(
|
||||
"update users " +
|
||||
"SET webLoginKey = ?webLoginKey " +
|
||||
"where UUID = ?UUID",
|
||||
param);
|
||||
updater.ExecuteNonQuery();
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
database.Reconnect();
|
||||
MainLog.Instance.Error(e.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -373,6 +373,29 @@ namespace OpenSim.Framework.Data.SQLite
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void StoreWebLoginKey(LLUUID AgentID, LLUUID WebLoginKey)
|
||||
{
|
||||
DataTable users = ds.Tables["users"];
|
||||
lock (ds)
|
||||
{
|
||||
DataRow row = users.Rows.Find(Util.ToRawUuidString(AgentID));
|
||||
if (row == null)
|
||||
{
|
||||
MainLog.Instance.Warn("WEBLOGIN", "Unable to store new web login key for non-existant user");
|
||||
}
|
||||
else
|
||||
{
|
||||
UserProfileData user = GetUserByUUID(AgentID);
|
||||
user.webLoginKey = WebLoginKey;
|
||||
fillUserRow(row, user);
|
||||
da.Update(ds, "users");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new user profile
|
||||
/// </summary>
|
||||
|
@ -392,6 +415,7 @@ namespace OpenSim.Framework.Data.SQLite
|
|||
else
|
||||
{
|
||||
fillUserRow(row, user);
|
||||
|
||||
}
|
||||
// This is why we're getting the 'logins never log-off'.. because It isn't clearing the
|
||||
// useragents table once the useragent is null
|
||||
|
|
|
@ -80,6 +80,12 @@ namespace OpenSim.Framework
|
|||
/// <returns>The current agent session</returns>
|
||||
UserAgentData GetAgentByName(string fname, string lname);
|
||||
|
||||
/// <summary>
|
||||
/// Stores new web-login key for user during web page login
|
||||
/// </summary>
|
||||
/// <param name="webLoginKey"></param>
|
||||
void StoreWebLoginKey(LLUUID agentID, LLUUID webLoginKey);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new User profile to the database
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue