From c313de630f2fec6793da2bc1f51dd54be82cb3e8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 15 Aug 2012 23:31:38 +0200 Subject: [PATCH] Add a real_id field to the login response if impersonation is used. The wrapper script needs this for proper logging. --- .../LocalAuthenticationServiceConnector.cs | 6 ++++++ .../PasswordAuthenticationService.cs | 10 ++++++++++ .../WebkeyAuthenticationService.cs | 7 +++++++ .../WebkeyOrPasswordAuthenticationService.cs | 16 +++++++++++++--- .../AuthenticationServicesConnector.cs | 7 +++++++ .../SimianAuthenticationServiceConnector.cs | 5 +++++ .../Interfaces/IAuthenticationService.cs | 1 + .../Services/LLLoginService/LLLoginResponse.cs | 13 ++++++++++++- .../Services/LLLoginService/LLLoginService.cs | 5 +++-- 9 files changed, 64 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs index 9484a5a282..25ee4c6fed 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs @@ -137,6 +137,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication #region IAuthenticationService + public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID) + { + // Not implemented at the regions + return string.Empty; + } + public string Authenticate(UUID principalID, string password, int lifetime) { // Not implemented at the regions diff --git a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs index 769c3c2477..9d12d477ec 100644 --- a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs @@ -64,6 +64,15 @@ namespace OpenSim.Services.AuthenticationService public string Authenticate(UUID principalID, string password, int lifetime) { + UUID realID; + + return Authenticate(principalID, password, lifetime, out realID); + } + + public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID) + { + realID = UUID.Zero; + m_log.DebugFormat("[AUTH SERVICE]: Authenticating for {0}, user account service present: {1}", principalID, m_UserAccountService != null); AuthenticationData data = m_Database.Get(principalID); UserAccount user = null; @@ -127,6 +136,7 @@ namespace OpenSim.Services.AuthenticationService if (data.Data["passwordHash"].ToString() == hashed) { m_log.DebugFormat("[PASS AUTH]: {0} {1} impersonating {2}, proceeding with login", a.FirstName, a.LastName, principalID); + realID = a.PrincipalID; return GetToken(principalID, lifetime); } // else diff --git a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs index d02ff9bc0b..47b4fa6ad0 100644 --- a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs @@ -60,6 +60,13 @@ namespace OpenSim.Services.AuthenticationService { } + public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID) + { + realID = UUID.Zero; + + return Authenticate(principalID, password, lifetime); + } + public string Authenticate(UUID principalID, string password, int lifetime) { if (new UUID(password) == UUID.Zero) diff --git a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs index 2c6cebdb7a..7fbf36dc3d 100644 --- a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs @@ -54,6 +54,13 @@ namespace OpenSim.Services.AuthenticationService } public string Authenticate(UUID principalID, string password, int lifetime) + { + UUID realID; + + return Authenticate(principalID, password, lifetime, out realID); + } + + public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID) { AuthenticationData data = m_Database.Get(principalID); string result = String.Empty; @@ -62,7 +69,7 @@ namespace OpenSim.Services.AuthenticationService if (data.Data.ContainsKey("webLoginKey")) { m_log.DebugFormat("[AUTH SERVICE]: Attempting web key authentication for PrincipalID {0}", principalID); - result = m_svcChecks["web_login_key"].Authenticate(principalID, password, lifetime); + result = m_svcChecks["web_login_key"].Authenticate(principalID, password, lifetime, out realID); if (result == String.Empty) { m_log.DebugFormat("[AUTH SERVICE]: Web Login failed for PrincipalID {0}", principalID); @@ -71,12 +78,15 @@ namespace OpenSim.Services.AuthenticationService if (result == string.Empty && data.Data.ContainsKey("passwordHash") && data.Data.ContainsKey("passwordSalt")) { m_log.DebugFormat("[AUTH SERVICE]: Attempting password authentication for PrincipalID {0}", principalID); - result = m_svcChecks["password"].Authenticate(principalID, password, lifetime); + result = m_svcChecks["password"].Authenticate(principalID, password, lifetime, out realID); if (result == String.Empty) { m_log.DebugFormat("[AUTH SERVICE]: Password login failed for PrincipalID {0}", principalID); } } + + realID = UUID.Zero; + if (result == string.Empty) { m_log.DebugFormat("[AUTH SERVICE]: Both password and webLoginKey-based authentication failed for PrincipalID {0}", principalID); @@ -89,4 +99,4 @@ namespace OpenSim.Services.AuthenticationService return result; } } -} \ No newline at end of file +} diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs index 2b77154a7b..f996acaf6b 100644 --- a/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs +++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs @@ -81,6 +81,13 @@ namespace OpenSim.Services.Connectors m_ServerURI = serviceURI; } + public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID) + { + realID = UUID.Zero; + + return Authenticate(principalID, password, lifetime); + } + public string Authenticate(UUID principalID, string password, int lifetime) { Dictionary sendData = new Dictionary(); diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs index 69f6ed2eac..331d485fd5 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs @@ -102,6 +102,11 @@ namespace OpenSim.Services.Connectors.SimianGrid m_log.Info("[SIMIAN AUTH CONNECTOR]: No AuthenticationServerURI specified, disabling connector"); } + public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID) + { + return Authenticate(principalID, password, lifetime); + } + public string Authenticate(UUID principalID, string password, int lifetime) { NameValueCollection requestArgs = new NameValueCollection diff --git a/OpenSim/Services/Interfaces/IAuthenticationService.cs b/OpenSim/Services/Interfaces/IAuthenticationService.cs index cee8bc09c7..cdcfad9cd9 100644 --- a/OpenSim/Services/Interfaces/IAuthenticationService.cs +++ b/OpenSim/Services/Interfaces/IAuthenticationService.cs @@ -67,6 +67,7 @@ namespace OpenSim.Services.Interfaces // various services. // string Authenticate(UUID principalID, string password, int lifetime); + string Authenticate(UUID principalID, string password, int lifetime, out UUID realID); ////////////////////////////////////////////////////// // Verification diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs index a4b3cbd16e..e2f947c1f7 100644 --- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs +++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs @@ -150,6 +150,7 @@ namespace OpenSim.Services.LLLoginService private UUID agentID; private UUID sessionID; private UUID secureSessionID; + private UUID realID; // Login Flags private string dst; @@ -232,7 +233,7 @@ namespace OpenSim.Services.LLLoginService GridRegion destination, List invSkel, FriendInfo[] friendsList, ILibraryService libService, string where, string startlocation, Vector3 position, Vector3 lookAt, List gestures, string message, GridRegion home, IPEndPoint clientIP, string mapTileURL, string profileURL, string openIDURL, string searchURL, string currency, - string DSTZone) + string DSTZone, UUID realID) : this() { FillOutInventoryData(invSkel, libService); @@ -245,6 +246,7 @@ namespace OpenSim.Services.LLLoginService AgentID = account.PrincipalID; SessionID = aCircuit.SessionID; SecureSessionID = aCircuit.SecureSessionID; + RealID = realID; Message = message; BuddList = ConvertFriendListItem(friendsList); StartLocation = where; @@ -456,6 +458,7 @@ namespace OpenSim.Services.LLLoginService SessionID = UUID.Random(); SecureSessionID = UUID.Random(); AgentID = UUID.Random(); + RealID = UUID.Zero; Hashtable InitialOutfitHash = new Hashtable(); InitialOutfitHash["folder_name"] = "Nightclub Female"; @@ -499,6 +502,7 @@ namespace OpenSim.Services.LLLoginService responseData["http_port"] = (Int32)SimHttpPort; responseData["agent_id"] = AgentID.ToString(); + responseData["real_id"] = RealID.ToString(); responseData["session_id"] = SessionID.ToString(); responseData["secure_session_id"] = SecureSessionID.ToString(); responseData["circuit_code"] = CircuitCode; @@ -581,6 +585,7 @@ namespace OpenSim.Services.LLLoginService map["sim_ip"] = OSD.FromString(SimAddress); map["agent_id"] = OSD.FromUUID(AgentID); + map["real_id"] = OSD.FromUUID(RealID); map["session_id"] = OSD.FromUUID(SessionID); map["secure_session_id"] = OSD.FromUUID(SecureSessionID); map["circuit_code"] = OSD.FromInteger(CircuitCode); @@ -888,6 +893,12 @@ namespace OpenSim.Services.LLLoginService set { secureSessionID = value; } } + public UUID RealID + { + get { return realID; } + set { realID = value; } + } + public Int32 CircuitCode { get { return circuitCode; } diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index ed887d9753..988a9b9305 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs @@ -327,7 +327,8 @@ namespace OpenSim.Services.LLLoginService 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 realID; + string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30, out realID); UUID secureSession = UUID.Zero; if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession))) { @@ -459,7 +460,7 @@ namespace OpenSim.Services.LLLoginService = new LLLoginResponse( account, aCircuit, guinfo, destination, inventorySkel, friendsList, m_LibraryService, where, startLocation, position, lookAt, gestures, m_WelcomeMessage, home, clientIP, - m_MapTileURL, m_ProfileURL, m_OpenIDURL, m_SearchURL, m_Currency, m_DSTZone); + m_MapTileURL, m_ProfileURL, m_OpenIDURL, m_SearchURL, m_Currency, m_DSTZone, realID); m_log.DebugFormat("[LLOGIN SERVICE]: All clear. Sending login response to {0} {1}", firstName, lastName);