diff options
Diffstat (limited to 'OpenSim/Services/HypergridService/GatekeeperService.cs')
-rw-r--r-- | OpenSim/Services/HypergridService/GatekeeperService.cs | 77 |
1 files changed, 32 insertions, 45 deletions
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; | |||
34 | using OpenSim.Services.Interfaces; | 34 | using OpenSim.Services.Interfaces; |
35 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 35 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
36 | using OpenSim.Server.Base; | 36 | using OpenSim.Server.Base; |
37 | using OpenSim.Services.Connectors.Hypergrid; | ||
37 | 38 | ||
38 | using OpenMetaverse; | 39 | using OpenMetaverse; |
39 | 40 | ||
@@ -50,9 +51,8 @@ namespace OpenSim.Services.HypergridService | |||
50 | 51 | ||
51 | IGridService m_GridService; | 52 | IGridService m_GridService; |
52 | IPresenceService m_PresenceService; | 53 | IPresenceService m_PresenceService; |
53 | IAuthenticationService m_AuthenticationService; | ||
54 | IUserAccountService m_UserAccountService; | 54 | IUserAccountService m_UserAccountService; |
55 | IHomeUsersSecurityService m_HomeUsersSecurityService; | 55 | IUserAgentService m_UserAgentService; |
56 | ISimulationService m_SimulationService; | 56 | ISimulationService m_SimulationService; |
57 | 57 | ||
58 | string m_AuthDll; | 58 | string m_AuthDll; |
@@ -69,12 +69,12 @@ namespace OpenSim.Services.HypergridService | |||
69 | throw new Exception(String.Format("No section GatekeeperService in config file")); | 69 | throw new Exception(String.Format("No section GatekeeperService in config file")); |
70 | 70 | ||
71 | string accountService = serverConfig.GetString("UserAccountService", String.Empty); | 71 | string accountService = serverConfig.GetString("UserAccountService", String.Empty); |
72 | string homeUsersSecurityService = serverConfig.GetString("HomeUsersSecurityService", string.Empty); | 72 | string homeUsersService = serverConfig.GetString("HomeUsersSecurityService", string.Empty); |
73 | string gridService = serverConfig.GetString("GridService", String.Empty); | 73 | string gridService = serverConfig.GetString("GridService", String.Empty); |
74 | string presenceService = serverConfig.GetString("PresenceService", String.Empty); | 74 | string presenceService = serverConfig.GetString("PresenceService", String.Empty); |
75 | string simulationService = serverConfig.GetString("SimulationService", String.Empty); | 75 | string simulationService = serverConfig.GetString("SimulationService", String.Empty); |
76 | 76 | ||
77 | m_AuthDll = serverConfig.GetString("AuthenticationService", String.Empty); | 77 | //m_AuthDll = serverConfig.GetString("AuthenticationService", String.Empty); |
78 | 78 | ||
79 | // These 3 are mandatory, the others aren't | 79 | // These 3 are mandatory, the others aren't |
80 | if (gridService == string.Empty || presenceService == string.Empty || m_AuthDll == string.Empty) | 80 | if (gridService == string.Empty || presenceService == string.Empty || m_AuthDll == string.Empty) |
@@ -92,8 +92,8 @@ namespace OpenSim.Services.HypergridService | |||
92 | 92 | ||
93 | if (accountService != string.Empty) | 93 | if (accountService != string.Empty) |
94 | m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args); | 94 | m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args); |
95 | if (homeUsersSecurityService != string.Empty) | 95 | if (homeUsersService != string.Empty) |
96 | m_HomeUsersSecurityService = ServerUtils.LoadPlugin<IHomeUsersSecurityService>(homeUsersSecurityService, args); | 96 | m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(homeUsersService, args); |
97 | 97 | ||
98 | if (simService != null) | 98 | if (simService != null) |
99 | m_SimulationService = simService; | 99 | m_SimulationService = simService; |
@@ -206,13 +206,12 @@ namespace OpenSim.Services.HypergridService | |||
206 | account = m_UserAccountService.GetUserAccount(m_ScopeID, aCircuit.AgentID); | 206 | account = m_UserAccountService.GetUserAccount(m_ScopeID, aCircuit.AgentID); |
207 | if (account != null) | 207 | if (account != null) |
208 | { | 208 | { |
209 | // Make sure this is the user coming home, and not a fake | 209 | // Make sure this is the user coming home, and not a foreign user with same UUID as a local user |
210 | if (m_HomeUsersSecurityService != null) | 210 | if (m_UserAgentService != null) |
211 | { | 211 | { |
212 | Object ep = m_HomeUsersSecurityService.GetEndPoint(aCircuit.SessionID); | 212 | if (!m_UserAgentService.AgentIsComingHome(aCircuit.SessionID, m_ExternalName)) |
213 | if (ep == null) | ||
214 | { | 213 | { |
215 | // This is a fake, this session never left this grid | 214 | // Can't do, sorry |
216 | reason = "Unauthorized"; | 215 | reason = "Unauthorized"; |
217 | m_log.InfoFormat("[GATEKEEPER SERVICE]: Foreign agent {0} {1} has same ID as local user. Refusing service.", | 216 | m_log.InfoFormat("[GATEKEEPER SERVICE]: Foreign agent {0} {1} has same ID as local user. Refusing service.", |
218 | aCircuit.firstname, aCircuit.lastname); | 217 | aCircuit.firstname, aCircuit.lastname); |
@@ -266,32 +265,35 @@ namespace OpenSim.Services.HypergridService | |||
266 | // | 265 | // |
267 | // Finally launch the agent at the destination | 266 | // Finally launch the agent at the destination |
268 | // | 267 | // |
269 | return m_SimulationService.CreateAgent(destination, aCircuit, 0, out reason); | 268 | return m_SimulationService.CreateAgent(destination, aCircuit, (uint)Constants.TeleportFlags.ViaLogin, out reason); |
270 | } | 269 | } |
271 | 270 | ||
272 | protected bool Authenticate(AgentCircuitData aCircuit) | 271 | protected bool Authenticate(AgentCircuitData aCircuit) |
273 | { | 272 | { |
274 | string authURL = string.Empty; | 273 | if (!CheckAddress(aCircuit.ServiceSessionID)) |
274 | return false; | ||
275 | |||
276 | string userURL = string.Empty; | ||
275 | if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) | 277 | if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) |
276 | authURL = aCircuit.ServiceURLs["HomeURI"].ToString(); | 278 | userURL = aCircuit.ServiceURLs["HomeURI"].ToString(); |
277 | 279 | ||
278 | if (authURL == string.Empty) | 280 | if (userURL == string.Empty) |
279 | { | 281 | { |
280 | m_log.DebugFormat("[GATEKEEPER SERVICE]: Agent did not provide an authentication server URL"); | 282 | m_log.DebugFormat("[GATEKEEPER SERVICE]: Agent did not provide an authentication server URL"); |
281 | return false; | 283 | return false; |
282 | } | 284 | } |
283 | 285 | ||
284 | Object[] args = new Object[] { authURL }; | 286 | Object[] args = new Object[] { userURL }; |
285 | IAuthenticationService authService = ServerUtils.LoadPlugin<IAuthenticationService>(m_AuthDll, args); | 287 | IUserAgentService userAgentService = new UserAgentServiceConnector(userURL); //ServerUtils.LoadPlugin<IUserAgentService>(m_AuthDll, args); |
286 | if (authService != null) | 288 | if (userAgentService != null) |
287 | { | 289 | { |
288 | try | 290 | try |
289 | { | 291 | { |
290 | return authService.Verify(aCircuit.AgentID, aCircuit.SecureSessionID.ToString(), 30); | 292 | return userAgentService.VerifyAgent(aCircuit.SessionID, aCircuit.ServiceSessionID); |
291 | } | 293 | } |
292 | catch | 294 | catch |
293 | { | 295 | { |
294 | m_log.DebugFormat("[GATEKEEPER SERVICE]: Unable to contact authentication service at {0}", authURL); | 296 | m_log.DebugFormat("[GATEKEEPER SERVICE]: Unable to contact authentication service at {0}", userURL); |
295 | return false; | 297 | return false; |
296 | } | 298 | } |
297 | } | 299 | } |
@@ -299,35 +301,20 @@ namespace OpenSim.Services.HypergridService | |||
299 | return false; | 301 | return false; |
300 | } | 302 | } |
301 | 303 | ||
302 | #endregion | 304 | // Check that the service token was generated for *this* grid. |
303 | 305 | // If it wasn't then that's a fake agent. | |
304 | public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt) | 306 | protected bool CheckAddress(string serviceToken) |
305 | { | 307 | { |
306 | position = new Vector3(128, 128, 0); lookAt = Vector3.UnitY; | 308 | string[] parts = serviceToken.Split(new char[] { ';' }); |
309 | if (parts.Length < 2) | ||
310 | return false; | ||
307 | 311 | ||
308 | m_log.DebugFormat("[GATEKEEPER SERVICE]: Request to get home region of user {0}", userID); | 312 | string addressee = parts[0]; |
313 | return (addressee == m_ExternalName); | ||
314 | } | ||
309 | 315 | ||
310 | GridRegion home = null; | 316 | #endregion |
311 | PresenceInfo[] presences = m_PresenceService.GetAgents(new string[] { userID.ToString() }); | ||
312 | if (presences != null && presences.Length > 0) | ||
313 | { | ||
314 | UUID homeID = presences[0].HomeRegionID; | ||
315 | if (homeID != UUID.Zero) | ||
316 | { | ||
317 | home = m_GridService.GetRegionByUUID(m_ScopeID, homeID); | ||
318 | position = presences[0].HomePosition; | ||
319 | lookAt = presences[0].HomeLookAt; | ||
320 | } | ||
321 | if (home == null) | ||
322 | { | ||
323 | List<GridRegion> defs = m_GridService.GetDefaultRegions(m_ScopeID); | ||
324 | if (defs != null && defs.Count > 0) | ||
325 | home = defs[0]; | ||
326 | } | ||
327 | } | ||
328 | 317 | ||
329 | return home; | ||
330 | } | ||
331 | 318 | ||
332 | #region Misc | 319 | #region Misc |
333 | 320 | ||