aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/HypergridService/GatekeeperService.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/HypergridService/GatekeeperService.cs116
1 files changed, 103 insertions, 13 deletions
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs
index 47d22b9..7b84d55 100644
--- a/OpenSim/Services/HypergridService/GatekeeperService.cs
+++ b/OpenSim/Services/HypergridService/GatekeeperService.cs
@@ -57,14 +57,18 @@ namespace OpenSim.Services.HypergridService
57 private static IUserAccountService m_UserAccountService; 57 private static IUserAccountService m_UserAccountService;
58 private static IUserAgentService m_UserAgentService; 58 private static IUserAgentService m_UserAgentService;
59 private static ISimulationService m_SimulationService; 59 private static ISimulationService m_SimulationService;
60 private static IGridUserService m_GridUserService;
60 61
61 protected string m_AllowedClients = string.Empty; 62 private static string m_AllowedClients = string.Empty;
62 protected string m_DeniedClients = string.Empty; 63 private static string m_DeniedClients = string.Empty;
63 private static bool m_ForeignAgentsAllowed = true; 64 private static bool m_ForeignAgentsAllowed = true;
65 private static List<string> m_ForeignsAllowedExceptions = new List<string>();
66 private static List<string> m_ForeignsDisallowedExceptions = new List<string>();
64 67
65 private static UUID m_ScopeID; 68 private static UUID m_ScopeID;
66 private static bool m_AllowTeleportsToAnyRegion; 69 private static bool m_AllowTeleportsToAnyRegion;
67 private static string m_ExternalName; 70 private static string m_ExternalName;
71 private static Uri m_Uri;
68 private static GridRegion m_DefaultGatewayRegion; 72 private static GridRegion m_DefaultGatewayRegion;
69 73
70 public GatekeeperService(IConfigSource config, ISimulationService simService) 74 public GatekeeperService(IConfigSource config, ISimulationService simService)
@@ -82,8 +86,9 @@ namespace OpenSim.Services.HypergridService
82 string gridService = serverConfig.GetString("GridService", String.Empty); 86 string gridService = serverConfig.GetString("GridService", String.Empty);
83 string presenceService = serverConfig.GetString("PresenceService", String.Empty); 87 string presenceService = serverConfig.GetString("PresenceService", String.Empty);
84 string simulationService = serverConfig.GetString("SimulationService", String.Empty); 88 string simulationService = serverConfig.GetString("SimulationService", String.Empty);
89 string gridUserService = serverConfig.GetString("GridUserService", String.Empty);
85 90
86 // These 3 are mandatory, the others aren't 91 // These are mandatory, the others aren't
87 if (gridService == string.Empty || presenceService == string.Empty) 92 if (gridService == string.Empty || presenceService == string.Empty)
88 throw new Exception("Incomplete specifications, Gatekeeper Service cannot function."); 93 throw new Exception("Incomplete specifications, Gatekeeper Service cannot function.");
89 94
@@ -95,6 +100,15 @@ namespace OpenSim.Services.HypergridService
95 if (m_ExternalName != string.Empty && !m_ExternalName.EndsWith("/")) 100 if (m_ExternalName != string.Empty && !m_ExternalName.EndsWith("/"))
96 m_ExternalName = m_ExternalName + "/"; 101 m_ExternalName = m_ExternalName + "/";
97 102
103 try
104 {
105 m_Uri = new Uri(m_ExternalName);
106 }
107 catch
108 {
109 m_log.WarnFormat("[GATEKEEPER SERVICE]: Malformed gatekeeper address {0}", m_ExternalName);
110 }
111
98 Object[] args = new Object[] { config }; 112 Object[] args = new Object[] { config };
99 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args); 113 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
100 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args); 114 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args);
@@ -103,6 +117,8 @@ namespace OpenSim.Services.HypergridService
103 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args); 117 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
104 if (homeUsersService != string.Empty) 118 if (homeUsersService != string.Empty)
105 m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(homeUsersService, args); 119 m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(homeUsersService, args);
120 if (gridUserService != string.Empty)
121 m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args);
106 122
107 if (simService != null) 123 if (simService != null)
108 m_SimulationService = simService; 124 m_SimulationService = simService;
@@ -113,6 +129,9 @@ namespace OpenSim.Services.HypergridService
113 m_DeniedClients = serverConfig.GetString("DeniedClients", string.Empty); 129 m_DeniedClients = serverConfig.GetString("DeniedClients", string.Empty);
114 m_ForeignAgentsAllowed = serverConfig.GetBoolean("ForeignAgentsAllowed", true); 130 m_ForeignAgentsAllowed = serverConfig.GetBoolean("ForeignAgentsAllowed", true);
115 131
132 LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_ForeignsAllowedExceptions);
133 LoadDomainExceptionsFromConfig(serverConfig, "DisallowExcept", m_ForeignsDisallowedExceptions);
134
116 if (m_GridService == null || m_PresenceService == null || m_SimulationService == null) 135 if (m_GridService == null || m_PresenceService == null || m_SimulationService == null)
117 throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function."); 136 throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function.");
118 137
@@ -125,6 +144,15 @@ namespace OpenSim.Services.HypergridService
125 { 144 {
126 } 145 }
127 146
147 protected void LoadDomainExceptionsFromConfig(IConfig config, string variable, List<string> exceptions)
148 {
149 string value = config.GetString(variable, string.Empty);
150 string[] parts = value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
151
152 foreach (string s in parts)
153 exceptions.Add(s.Trim());
154 }
155
128 public bool LinkRegion(string regionName, out UUID regionID, out ulong regionHandle, out string externalName, out string imageURL, out string reason) 156 public bool LinkRegion(string regionName, out UUID regionID, out ulong regionHandle, out string externalName, out string imageURL, out string reason)
129 { 157 {
130 regionID = UUID.Zero; 158 regionID = UUID.Zero;
@@ -260,17 +288,26 @@ namespace OpenSim.Services.HypergridService
260 m_log.DebugFormat("[GATEKEEPER SERVICE]: User is ok"); 288 m_log.DebugFormat("[GATEKEEPER SERVICE]: User is ok");
261 289
262 // 290 //
263 // Foreign agents allowed 291 // Foreign agents allowed? Exceptions?
264 // 292 //
265 if (account == null && !m_ForeignAgentsAllowed) 293 if (account == null)
266 { 294 {
267 reason = "Unauthorized"; 295 bool allowed = m_ForeignAgentsAllowed;
268 m_log.InfoFormat("[GATEKEEPER SERVICE]: Foreign agents are not permitted {0} {1}. Refusing service.",
269 aCircuit.firstname, aCircuit.lastname);
270 return false;
271 }
272 296
273 // May want to authorize 297 if (m_ForeignAgentsAllowed && IsException(aCircuit, m_ForeignsAllowedExceptions))
298 allowed = false;
299
300 if (!m_ForeignAgentsAllowed && IsException(aCircuit, m_ForeignsDisallowedExceptions))
301 allowed = true;
302
303 if (!allowed)
304 {
305 reason = "Destination does not allow visitors from your world";
306 m_log.InfoFormat("[GATEKEEPER SERVICE]: Foreign agents are not permitted {0} {1} @ {2}. Refusing service.",
307 aCircuit.firstname, aCircuit.lastname, aCircuit.ServiceURLs["HomeURI"]);
308 return false;
309 }
310 }
274 311
275 bool isFirstLogin = false; 312 bool isFirstLogin = false;
276 // 313 //
@@ -280,7 +317,8 @@ namespace OpenSim.Services.HypergridService
280 if (presence != null) // it has been placed there by the login service 317 if (presence != null) // it has been placed there by the login service
281 isFirstLogin = true; 318 isFirstLogin = true;
282 319
283 else 320 else
321 {
284 if (!m_PresenceService.LoginAgent(aCircuit.AgentID.ToString(), aCircuit.SessionID, aCircuit.SecureSessionID)) 322 if (!m_PresenceService.LoginAgent(aCircuit.AgentID.ToString(), aCircuit.SessionID, aCircuit.SecureSessionID))
285 { 323 {
286 reason = "Unable to login presence"; 324 reason = "Unable to login presence";
@@ -290,6 +328,26 @@ namespace OpenSim.Services.HypergridService
290 } 328 }
291 m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence ok"); 329 m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence ok");
292 330
331 // Also login foreigners with GridUser service
332 if (m_GridUserService != null && account == null)
333 {
334 string userId = aCircuit.AgentID.ToString();
335 string first = aCircuit.firstname, last = aCircuit.lastname;
336 if (last.StartsWith("@"))
337 {
338 string[] parts = aCircuit.firstname.Split('.');
339 if (parts.Length >= 2)
340 {
341 first = parts[0];
342 last = parts[1];
343 }
344 }
345
346 userId += ";" + aCircuit.ServiceURLs["HomeURI"] + ";" + first + " " + last;
347 m_GridUserService.LoggedIn(userId);
348 }
349 }
350
293 // 351 //
294 // Get the region 352 // Get the region
295 // 353 //
@@ -385,7 +443,18 @@ namespace OpenSim.Services.HypergridService
385 string externalname = m_ExternalName.TrimEnd(trailing_slash); 443 string externalname = m_ExternalName.TrimEnd(trailing_slash);
386 m_log.DebugFormat("[GATEKEEPER SERVICE]: Verifying {0} against {1}", addressee, externalname); 444 m_log.DebugFormat("[GATEKEEPER SERVICE]: Verifying {0} against {1}", addressee, externalname);
387 445
388 return string.Equals(addressee, externalname, StringComparison.OrdinalIgnoreCase); 446 Uri uri;
447 try
448 {
449 uri = new Uri(addressee);
450 }
451 catch
452 {
453 m_log.DebugFormat("[GATEKEEPER SERVICE]: Visitor provided malformed service address {0}", addressee);
454 return false;
455 }
456
457 return string.Equals(uri.GetLeftPart(UriPartial.Authority), m_Uri.GetLeftPart(UriPartial.Authority), StringComparison.OrdinalIgnoreCase) ;
389 } 458 }
390 459
391 #endregion 460 #endregion
@@ -393,6 +462,27 @@ namespace OpenSim.Services.HypergridService
393 462
394 #region Misc 463 #region Misc
395 464
465 private bool IsException(AgentCircuitData aCircuit, List<string> exceptions)
466 {
467 bool exception = false;
468 if (exceptions.Count > 0) // we have exceptions
469 {
470 // Retrieve the visitor's origin
471 string userURL = aCircuit.ServiceURLs["HomeURI"].ToString();
472 if (!userURL.EndsWith("/"))
473 userURL += "/";
474
475 if (exceptions.Find(delegate(string s)
476 {
477 if (!s.EndsWith("/"))
478 s += "/";
479 return s == userURL;
480 }) != null)
481 exception = true;
482 }
483
484 return exception;
485 }
396 486
397 #endregion 487 #endregion
398 } 488 }