New LL login service is working! -- tested in standalone only. Things still missing from response, namely Library and Friends. Appearance service is also missing.

slimupdates
Diva Canto 2010-01-01 16:54:24 -08:00
parent 4bca697865
commit 4240f2dec6
10 changed files with 188 additions and 116 deletions

View File

@ -128,7 +128,7 @@ namespace OpenSim.Data
return;
// to prevent people from killing long migrations.
m_log.InfoFormat("[MIGRATIONS] Upgrading {0} to latest revision.", _type);
m_log.InfoFormat("[MIGRATIONS] Upgrading {0} to latest revision {1}.", _type, migrations.Keys[migrations.Count - 1]);
m_log.Info("[MIGRATIONS] NOTE: this may take a while, don't interupt this process!");
DbCommand cmd = _conn.CreateCommand();
@ -144,7 +144,8 @@ namespace OpenSim.Data
}
catch (Exception e)
{
m_log.Debug("[MIGRATIONS]: An error has occurred in the migration. This may mean you could see errors trying to run OpenSim. If you see database related errors, you will need to fix the issue manually. Continuing.");
m_log.DebugFormat("[MIGRATIONS] Cmd was {0}", cmd.CommandText);
m_log.DebugFormat("[MIGRATIONS]: An error has occurred in the migration {0}.\n This may mean you could see errors trying to run OpenSim. If you see database related errors, you will need to fix the issue manually. Continuing.", e.Message);
}
if (version == 0)
@ -253,7 +254,8 @@ namespace OpenSim.Data
if (m.Success)
{
int version = int.Parse(m.Groups[1].ToString());
if (version > after) {
if (version > after)
{
using (Stream resource = _assem.GetManifestResourceStream(s))
{
using (StreamReader resourceReader = new StreamReader(resource))

View File

@ -81,12 +81,12 @@ namespace OpenSim.Data.MySQL
MySqlCommand cmd = new MySqlCommand();
cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, Position=?Position, LookAt=?LookAt', Online='true' where `SessionID`=?SessionID", m_Realm);
cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, Position=?Position, LookAt=?LookAt, Online='true' where `SessionID`=?SessionID", m_Realm);
cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString());
cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
cmd.Parameters.AddWithValue("?Position", position);
cmd.Parameters.AddWithValue("?LookAt", lookAt);
cmd.Parameters.AddWithValue("?Position", position.ToString());
cmd.Parameters.AddWithValue("?LookAt", lookAt.ToString());
if (ExecuteNonQuery(cmd) == 0)
return false;

View File

@ -32,6 +32,8 @@
<!-- Service connectors OUT modules -->
<RegionModule id="LocalAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.LocalAssetServicesConnector" />
<RegionModule id="RemoteAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.RemoteAssetServicesConnector" />
<RegionModule id="LocalAuthenticationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication.LocalAuthenticationServicesConnector" />
<RegionModule id="RemoteAuthenticationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication.RemoteAuthenticationServicesConnector" />
<RegionModule id="LocalAuthorizationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization.LocalAuthorizationServicesConnector" />
<RegionModule id="RemoteAuthorizationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization.RemoteAuthorizationServicesConnector" />
<RegionModule id="HGAssetBroker" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.HGAssetBroker" />

View File

@ -3483,10 +3483,18 @@ namespace OpenSim.Region.Framework.Scenes
{
reason = String.Empty;
bool result = CommsManager.UserService.VerifySession(agent.AgentID, agent.SessionID);
m_log.Debug("[CONNECTION BEGIN]: User authentication returned " + result);
IAuthenticationService auth = RequestModuleInterface<IAuthenticationService>();
if (auth == null)
{
reason = String.Format("Failed to authenticate user {0} {1} in region {2}. Authentication service does not exist.", agent.firstname, agent.lastname, RegionInfo.RegionName);
return false;
}
bool result = auth.Verify(agent.AgentID, agent.SecureSessionID.ToString(), 30);
m_log.Debug("[CONNECTION BEGIN]: Session authentication returned " + result);
if (!result)
reason = String.Format("Failed to authenticate user {0} {1}, access denied.", agent.firstname, agent.lastname);
reason = String.Format("Failed to authenticate user {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName);
return result;
}

View File

@ -47,9 +47,9 @@ namespace OpenSim.Services.AuthenticationService
public class PasswordAuthenticationService :
AuthenticationServiceBase, IAuthenticationService
{
// private static readonly ILog m_log =
// LogManager.GetLogger(
// MethodBase.GetCurrentMethod().DeclaringType);
//private static readonly ILog m_log =
// LogManager.GetLogger(
// MethodBase.GetCurrentMethod().DeclaringType);
public PasswordAuthenticationService(IConfigSource config) :
base(config)
@ -69,6 +69,8 @@ namespace OpenSim.Services.AuthenticationService
string hashed = Util.Md5Hash(password + ":" +
data.Data["passwordSalt"].ToString());
//m_log.DebugFormat("[PASS AUTH]: got {0}; hashed = {1}; stored = {2}", password, hashed, data.Data["passwordHash"].ToString());
if (data.Data["passwordHash"].ToString() == hashed)
{
return GetToken(principalID, lifetime);

View File

@ -67,7 +67,7 @@ namespace OpenSim.Services.Connectors
IConfig assetConfig = source.Configs["AuthenticationService"];
if (assetConfig == null)
{
m_log.Error("[USER CONNECTOR]: AuthenticationService missing from OpanSim.ini");
m_log.Error("[AUTH CONNECTOR]: AuthenticationService missing from OpanSim.ini");
throw new Exception("Authentication connector init error");
}
@ -76,7 +76,7 @@ namespace OpenSim.Services.Connectors
if (serviceURI == String.Empty)
{
m_log.Error("[USER CONNECTOR]: No Server URI named in section AuthenticationService");
m_log.Error("[AUTH CONNECTOR]: No Server URI named in section AuthenticationService");
throw new Exception("Authentication connector init error");
}
m_ServerURI = serviceURI;

View File

@ -51,6 +51,7 @@ namespace OpenSim.Services.LLLoginService
string m_login;
public static LLFailedLoginResponse UserProblem;
public static LLFailedLoginResponse AuthorizationProblem;
public static LLFailedLoginResponse GridProblem;
public static LLFailedLoginResponse InventoryProblem;
public static LLFailedLoginResponse DeadRegionProblem;
@ -63,8 +64,11 @@ namespace OpenSim.Services.LLLoginService
UserProblem = new LLFailedLoginResponse("key",
"Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.",
"false");
AuthorizationProblem = new LLFailedLoginResponse("key",
"Error connecting to grid. Unable to authorize your session into the region.",
"false");
GridProblem = new LLFailedLoginResponse("key",
"Error connecting to grid. Could not percieve credentials from login XML.",
"Error connecting to the desired location. Try connecting to another region.",
"false");
InventoryProblem = new LLFailedLoginResponse("key",
"The inventory service is not responding. Please notify your login region operator.",
@ -288,8 +292,8 @@ namespace OpenSim.Services.LLLoginService
Home = string.Format(
"{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
home.RegionLocX,
home.RegionLocY,
x,
y,
pinfo.HomePosition.X, pinfo.HomePosition.Y, pinfo.HomePosition.Z,
pinfo.HomeLookAt.X, pinfo.HomeLookAt.Y, pinfo.HomeLookAt.Z);
@ -441,8 +445,8 @@ namespace OpenSim.Services.LLLoginService
responseData["home"] = home;
responseData["look_at"] = lookAt;
responseData["message"] = welcomeMessage;
responseData["region_x"] = (Int32)(RegionX * Constants.RegionSize);
responseData["region_y"] = (Int32)(RegionY * Constants.RegionSize);
responseData["region_x"] = (Int32)(RegionX);
responseData["region_y"] = (Int32)(RegionY);
if (m_buddyList != null)
{
@ -537,8 +541,8 @@ namespace OpenSim.Services.LLLoginService
map["home"] = OSD.FromString(home);
map["look_at"] = OSD.FromString(lookAt);
map["message"] = OSD.FromString(welcomeMessage);
map["region_x"] = OSD.FromInteger(RegionX * Constants.RegionSize);
map["region_y"] = OSD.FromInteger(RegionY * Constants.RegionSize);
map["region_x"] = OSD.FromInteger(RegionX);
map["region_y"] = OSD.FromInteger(RegionY);
if (m_buddyList != null)
{

View File

@ -75,104 +75,120 @@ namespace OpenSim.Services.LLLoginService
public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, IPEndPoint clientIP)
{
bool success = false;
// Get the account and check that it exists
UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName);
if (account == null)
{
m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: user not found");
return LLFailedLoginResponse.UserProblem;
}
// Authenticate this user
string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30);
UUID secureSession = UUID.Zero;
if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession)))
{
m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: authentication failed");
return LLFailedLoginResponse.UserProblem;
}
// Get the user's inventory
List<InventoryFolderBase> inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID);
if (m_RequireInventory && ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0)))
{
m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: unable to retrieve user inventory");
return LLFailedLoginResponse.InventoryProblem;
}
// Login the presence
// We may want to check for user already logged in, to
// stay compatible with what people expect...
UUID session = UUID.Random();
PresenceInfo presence = null;
GridRegion home = null;
if (m_PresenceService != null)
try
{
success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession);
if (!success)
// Get the account and check that it exists
UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName);
if (account == null)
{
m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: could not login presence");
m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: user not found");
return LLFailedLoginResponse.UserProblem;
}
// Authenticate this user
if (!passwd.StartsWith("$1$"))
passwd = "$1$" + Util.Md5Hash(passwd);
passwd = passwd.Remove(0, 3); //remove $1$
string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30);
UUID secureSession = UUID.Zero;
if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession)))
{
m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: authentication failed");
return LLFailedLoginResponse.UserProblem;
}
// Get the user's inventory
List<InventoryFolderBase> inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID);
if (m_RequireInventory && ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0)))
{
m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: unable to retrieve user inventory");
return LLFailedLoginResponse.InventoryProblem;
}
// Login the presence
// We may want to check for user already logged in, to
// stay compatible with what people expect...
PresenceInfo presence = null;
GridRegion home = null;
if (m_PresenceService != null)
{
success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession);
if (!success)
{
m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: could not login presence");
return LLFailedLoginResponse.GridProblem;
}
// Get the updated presence info
presence = m_PresenceService.GetAgent(session);
// Get the home region
if ((presence.HomeRegionID != UUID.Zero) && m_GridService != null)
{
home = m_GridService.GetRegionByUUID(account.ScopeID, presence.HomeRegionID);
}
}
// Find the destination region/grid
string where = string.Empty;
Vector3 position = Vector3.Zero;
Vector3 lookAt = Vector3.Zero;
GridRegion destination = FindDestination(account, presence, session, startLocation, out where, out position, out lookAt);
if (destination == null)
{
m_PresenceService.LogoutAgent(session);
m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: destination not found");
return LLFailedLoginResponse.GridProblem;
}
// Get the updated presence info
presence = m_PresenceService.GetAgent(session);
// Get the home region
if ((presence.HomeRegionID != UUID.Zero) && m_GridService != null)
// Instantiate/get the simulation interface and launch an agent at the destination
ISimulationService simConnector = null;
string reason = string.Empty;
uint circuitCode = 0;
AgentCircuitData aCircuit = null;
Object[] args = new Object[] { destination };
// HG standalones have both a localSimulatonDll and a remoteSimulationDll
// non-HG standalones have just a localSimulationDll
// independent login servers have just a remoteSimulationDll
if (!startLocation.Contains("@") && (m_LocalSimulationService != null))
simConnector = m_LocalSimulationService;
else if (m_RemoteSimulationDll != string.Empty)
simConnector = ServerUtils.LoadPlugin<ISimulationService>(m_RemoteSimulationDll, args);
if (simConnector != null)
{
home = m_GridService.GetRegionByUUID(account.ScopeID, presence.HomeRegionID);
circuitCode = (uint)Util.RandomClass.Next(); ;
aCircuit = LaunchAgent(simConnector, destination, account, session, secureSession, circuitCode, position, out reason);
}
if (aCircuit == null)
{
m_PresenceService.LogoutAgent(session);
m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: {0}", reason);
return LLFailedLoginResponse.AuthorizationProblem;
}
}
// Find the destination region/grid
string where = string.Empty;
Vector3 position = Vector3.Zero;
Vector3 lookAt = Vector3.Zero;
GridRegion destination = FindDestination(account, presence, session, startLocation, out where, out position, out lookAt);
if (destination == null)
// TODO: Get Friends list...
// Finally, fill out the response and return it
LLLoginResponse response = new LLLoginResponse(account, aCircuit, presence, destination, inventorySkel,
where, startLocation, position, lookAt, m_WelcomeMessage, home, clientIP);
return response;
}
catch (Exception e)
{
m_PresenceService.LogoutAgent(session);
m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: destination not found");
return LLFailedLoginResponse.GridProblem;
m_log.WarnFormat("[LLOGIN SERVICE]: Exception processing login for {0} {1}: {2}", firstName, lastName, e.StackTrace);
if (m_PresenceService != null)
m_PresenceService.LogoutAgent(session);
return LLFailedLoginResponse.InternalError;
}
// Instantiate/get the simulation interface and launch an agent at the destination
ISimulationService simConnector = null;
string reason = string.Empty;
uint circuitCode = 0;
AgentCircuitData aCircuit = null;
Object[] args = new Object[] { destination };
// HG standalones have both a localSimulatonDll and a remoteSimulationDll
// non-HG standalones have just a localSimulationDll
// independent login servers have just a remoteSimulationDll
if (!startLocation.Contains("@") && (m_LocalSimulationService != null))
simConnector = m_LocalSimulationService;
else if (m_RemoteSimulationDll != string.Empty)
simConnector = ServerUtils.LoadPlugin<ISimulationService>(m_RemoteSimulationDll, args);
if (simConnector != null)
{
circuitCode = (uint)Util.RandomClass.Next(); ;
aCircuit = LaunchAgent(simConnector, destination, account, session, secureSession, circuitCode, position, out reason);
}
if (aCircuit == null)
{
m_PresenceService.LogoutAgent(session);
m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: {0}", reason);
return LLFailedLoginResponse.GridProblem;
}
// TODO: Get Friends list...
// Finally, fill out the response and return it
LLLoginResponse response = new LLLoginResponse(account, aCircuit, presence, destination, inventorySkel,
where, startLocation, position, lookAt, m_WelcomeMessage, home, clientIP);
return response;
}
private GridRegion FindDestination(UserAccount account, PresenceInfo pinfo, UUID sessionID, string startLocation, out string where, out Vector3 position, out Vector3 lookAt)
{
m_log.DebugFormat("[LLOGIN SERVICE]: FindDestination for start location {0}", startLocation);
where = "home";
position = new Vector3(128, 128, 0);
lookAt = new Vector3(0, 1, 0);
@ -188,7 +204,16 @@ namespace OpenSim.Services.LLLoginService
GridRegion region = null;
if (pinfo.HomeRegionID.Equals(UUID.Zero))
region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName);
{
if (m_DefaultRegionName != string.Empty)
{
region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName);
where = "safe";
}
else
m_log.WarnFormat("[LLOGIN SERVICE]: User {0} {1} does not have a home set and this grid does not have a default location." +
"Please specify DefaultLocation in [LoginService]", account.FirstName, account.LastName);
}
else
region = m_GridService.GetRegionByUUID(account.ScopeID, pinfo.HomeRegionID);
@ -207,7 +232,10 @@ namespace OpenSim.Services.LLLoginService
GridRegion region = null;
if (pinfo.RegionID.Equals(UUID.Zero))
{
region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName);
where = "safe";
}
else
{
region = m_GridService.GetRegionByUUID(account.ScopeID, pinfo.RegionID);
@ -240,6 +268,9 @@ namespace OpenSim.Services.LLLoginService
{
if (!regionName.Contains("@"))
{
if (m_GridService == null)
return null;
List<GridRegion> regions = m_GridService.GetRegionsByName(account.ScopeID, regionName, 1);
if ((regions == null) || (regions != null && regions.Count == 0))
{

View File

@ -63,15 +63,22 @@ namespace OpenSim.Services.PresenceService
data.UserID = userID;
data.RegionID = UUID.Zero;
data.SessionID = sessionID;
data.Data = new Dictionary<string, string>();
data.Data["SecureSessionID"] = secureSessionID.ToString();
data.Data["Online"] = "true";
data.Data["Login"] = Util.UnixTimeSinceEpoch().ToString();
if (d.Length > 0)
if (d != null && d.Length > 0)
{
data.Data["HomeRegionID"] = d[0].Data["HomeRegionID"];
data.Data["HomePosition"] = d[0].Data["HomePosition"];
data.Data["HomeLookAt"] = d[0].Data["HomeLookAt"];
}
else
{
data.Data["HomeRegionID"] = UUID.Zero.ToString();
data.Data["HomePosition"] = new Vector3(128, 128, 0).ToString();
data.Data["HomeLookAt"] = new Vector3(0, 1, 0).ToString();
}
m_Database.Store(data);
@ -86,9 +93,10 @@ namespace OpenSim.Services.PresenceService
PresenceData[] d = m_Database.Get("UserID", data.UserID);
m_log.WarnFormat("[PRESENCE SERVICE]: LogoutAgent {0} with {1} sessions currently present", data.UserID, d.Length);
if (d.Length > 1)
{
m_Database.Delete("SessionID", sessionID.ToString());
m_Database.Delete("UserID", data.UserID);
}
data.Data["Online"] = "false";
@ -110,14 +118,28 @@ namespace OpenSim.Services.PresenceService
public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt)
{
m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent with session {0} in region {1}", sessionID, regionID);
PresenceData pdata = m_Database.Get(sessionID);
if (pdata == null)
return false;
if (pdata.Data["Online"] == "false")
return false;
try
{
PresenceData pdata = m_Database.Get(sessionID);
if (pdata == null)
return false;
if (pdata.Data == null)
return false;
return m_Database.ReportAgent(sessionID, regionID,
position.ToString(), lookAt.ToString());
if (!pdata.Data.ContainsKey("Online") || (pdata.Data.ContainsKey("Online") && pdata.Data["Online"] == "false"))
{
m_log.WarnFormat("[PRESENCE SERVICE]: Someone tried to report presence of an agent who's not online");
return false;
}
return m_Database.ReportAgent(sessionID, regionID,
position.ToString(), lookAt.ToString());
}
catch (Exception e)
{
m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent threw exception {0}", e.StackTrace);
return false;
}
}
public PresenceInfo GetAgent(UUID sessionID)

View File

@ -14,6 +14,7 @@
AssetServices = "HGAssetBroker"
InventoryServices = "HGInventoryBroker"
NeighbourServices = "RemoteNeighbourServicesConnector"
AuthenticationServices = "LocalAuthenticationServicesConnector"
AuthorizationServices = "LocalAuthorizationServicesConnector"
GridServices = "HGGridServicesConnector"
PresenceServices = "LocalPresenceServicesConnector"
@ -46,8 +47,7 @@
LocalServiceModule = "OpenSim.Services.AuthorizationService.dll:AuthorizationService"
[AuthenticationService]
; For the HGAuthServiceInConnector
LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:HGAuthenticationService"
LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"
[GridService]
; for the HGGridServicesConnector to instantiate
@ -68,4 +68,5 @@
AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"
InventoryService = "OpenSim.Services.InventoryService.dll:InventoryService"
PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService"
GridService = "OpenSim.Services.GridService.dll:GridService"