From 00f7d622cbc2c2e61d2efaacd8275da3f9821d8b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 28 Jan 2010 19:19:42 -0800 Subject: HG 1.5 is in place. Tested in standalone only. --- .../Services/HypergridService/GatekeeperService.cs | 77 +++++++++------------- 1 file changed, 32 insertions(+), 45 deletions(-) (limited to 'OpenSim/Services/HypergridService/GatekeeperService.cs') diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs index 3cb5d50..3bf0836 100644 --- a/OpenSim/Services/HypergridService/GatekeeperService.cs +++ b/OpenSim/Services/HypergridService/GatekeeperService.cs @@ -34,6 +34,7 @@ using OpenSim.Framework; using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Server.Base; +using OpenSim.Services.Connectors.Hypergrid; using OpenMetaverse; @@ -50,9 +51,8 @@ namespace OpenSim.Services.HypergridService IGridService m_GridService; IPresenceService m_PresenceService; - IAuthenticationService m_AuthenticationService; IUserAccountService m_UserAccountService; - IHomeUsersSecurityService m_HomeUsersSecurityService; + IUserAgentService m_UserAgentService; ISimulationService m_SimulationService; string m_AuthDll; @@ -69,12 +69,12 @@ namespace OpenSim.Services.HypergridService throw new Exception(String.Format("No section GatekeeperService in config file")); string accountService = serverConfig.GetString("UserAccountService", String.Empty); - string homeUsersSecurityService = serverConfig.GetString("HomeUsersSecurityService", string.Empty); + string homeUsersService = serverConfig.GetString("HomeUsersSecurityService", string.Empty); string gridService = serverConfig.GetString("GridService", String.Empty); string presenceService = serverConfig.GetString("PresenceService", String.Empty); string simulationService = serverConfig.GetString("SimulationService", String.Empty); - m_AuthDll = serverConfig.GetString("AuthenticationService", String.Empty); + //m_AuthDll = serverConfig.GetString("AuthenticationService", String.Empty); // These 3 are mandatory, the others aren't if (gridService == string.Empty || presenceService == string.Empty || m_AuthDll == string.Empty) @@ -92,8 +92,8 @@ namespace OpenSim.Services.HypergridService if (accountService != string.Empty) m_UserAccountService = ServerUtils.LoadPlugin(accountService, args); - if (homeUsersSecurityService != string.Empty) - m_HomeUsersSecurityService = ServerUtils.LoadPlugin(homeUsersSecurityService, args); + if (homeUsersService != string.Empty) + m_UserAgentService = ServerUtils.LoadPlugin(homeUsersService, args); if (simService != null) m_SimulationService = simService; @@ -206,13 +206,12 @@ namespace OpenSim.Services.HypergridService account = m_UserAccountService.GetUserAccount(m_ScopeID, aCircuit.AgentID); if (account != null) { - // Make sure this is the user coming home, and not a fake - if (m_HomeUsersSecurityService != null) + // Make sure this is the user coming home, and not a foreign user with same UUID as a local user + if (m_UserAgentService != null) { - Object ep = m_HomeUsersSecurityService.GetEndPoint(aCircuit.SessionID); - if (ep == null) + if (!m_UserAgentService.AgentIsComingHome(aCircuit.SessionID, m_ExternalName)) { - // This is a fake, this session never left this grid + // Can't do, sorry reason = "Unauthorized"; m_log.InfoFormat("[GATEKEEPER SERVICE]: Foreign agent {0} {1} has same ID as local user. Refusing service.", aCircuit.firstname, aCircuit.lastname); @@ -266,32 +265,35 @@ namespace OpenSim.Services.HypergridService // // Finally launch the agent at the destination // - return m_SimulationService.CreateAgent(destination, aCircuit, 0, out reason); + return m_SimulationService.CreateAgent(destination, aCircuit, (uint)Constants.TeleportFlags.ViaLogin, out reason); } protected bool Authenticate(AgentCircuitData aCircuit) { - string authURL = string.Empty; + if (!CheckAddress(aCircuit.ServiceSessionID)) + return false; + + string userURL = string.Empty; if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) - authURL = aCircuit.ServiceURLs["HomeURI"].ToString(); + userURL = aCircuit.ServiceURLs["HomeURI"].ToString(); - if (authURL == string.Empty) + if (userURL == string.Empty) { m_log.DebugFormat("[GATEKEEPER SERVICE]: Agent did not provide an authentication server URL"); return false; } - Object[] args = new Object[] { authURL }; - IAuthenticationService authService = ServerUtils.LoadPlugin(m_AuthDll, args); - if (authService != null) + Object[] args = new Object[] { userURL }; + IUserAgentService userAgentService = new UserAgentServiceConnector(userURL); //ServerUtils.LoadPlugin(m_AuthDll, args); + if (userAgentService != null) { try { - return authService.Verify(aCircuit.AgentID, aCircuit.SecureSessionID.ToString(), 30); + return userAgentService.VerifyAgent(aCircuit.SessionID, aCircuit.ServiceSessionID); } catch { - m_log.DebugFormat("[GATEKEEPER SERVICE]: Unable to contact authentication service at {0}", authURL); + m_log.DebugFormat("[GATEKEEPER SERVICE]: Unable to contact authentication service at {0}", userURL); return false; } } @@ -299,35 +301,20 @@ namespace OpenSim.Services.HypergridService return false; } - #endregion - - public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt) + // Check that the service token was generated for *this* grid. + // If it wasn't then that's a fake agent. + protected bool CheckAddress(string serviceToken) { - position = new Vector3(128, 128, 0); lookAt = Vector3.UnitY; + string[] parts = serviceToken.Split(new char[] { ';' }); + if (parts.Length < 2) + return false; - m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to get home region of user {0}", userID); + string addressee = parts[0]; + return (addressee == m_ExternalName); + } - GridRegion home = null; - PresenceInfo[] presences = m_PresenceService.GetAgents(new string[] { userID.ToString() }); - if (presences != null && presences.Length > 0) - { - UUID homeID = presences[0].HomeRegionID; - if (homeID != UUID.Zero) - { - home = m_GridService.GetRegionByUUID(m_ScopeID, homeID); - position = presences[0].HomePosition; - lookAt = presences[0].HomeLookAt; - } - if (home == null) - { - List defs = m_GridService.GetDefaultRegions(m_ScopeID); - if (defs != null && defs.Count > 0) - home = defs[0]; - } - } + #endregion - return home; - } #region Misc -- cgit v1.1