aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/HypergridService/GatekeeperService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/HypergridService/GatekeeperService.cs')
-rw-r--r--OpenSim/Services/HypergridService/GatekeeperService.cs93
1 files changed, 81 insertions, 12 deletions
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs
index 47d22b9..004311f 100644
--- a/OpenSim/Services/HypergridService/GatekeeperService.cs
+++ b/OpenSim/Services/HypergridService/GatekeeperService.cs
@@ -57,10 +57,13 @@ 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;
@@ -82,8 +85,9 @@ namespace OpenSim.Services.HypergridService
82 string gridService = serverConfig.GetString("GridService", String.Empty); 85 string gridService = serverConfig.GetString("GridService", String.Empty);
83 string presenceService = serverConfig.GetString("PresenceService", String.Empty); 86 string presenceService = serverConfig.GetString("PresenceService", String.Empty);
84 string simulationService = serverConfig.GetString("SimulationService", String.Empty); 87 string simulationService = serverConfig.GetString("SimulationService", String.Empty);
88 string gridUserService = serverConfig.GetString("GridUserService", String.Empty);
85 89
86 // These 3 are mandatory, the others aren't 90 // These are mandatory, the others aren't
87 if (gridService == string.Empty || presenceService == string.Empty) 91 if (gridService == string.Empty || presenceService == string.Empty)
88 throw new Exception("Incomplete specifications, Gatekeeper Service cannot function."); 92 throw new Exception("Incomplete specifications, Gatekeeper Service cannot function.");
89 93
@@ -103,6 +107,8 @@ namespace OpenSim.Services.HypergridService
103 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args); 107 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
104 if (homeUsersService != string.Empty) 108 if (homeUsersService != string.Empty)
105 m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(homeUsersService, args); 109 m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(homeUsersService, args);
110 if (gridUserService != string.Empty)
111 m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args);
106 112
107 if (simService != null) 113 if (simService != null)
108 m_SimulationService = simService; 114 m_SimulationService = simService;
@@ -113,6 +119,9 @@ namespace OpenSim.Services.HypergridService
113 m_DeniedClients = serverConfig.GetString("DeniedClients", string.Empty); 119 m_DeniedClients = serverConfig.GetString("DeniedClients", string.Empty);
114 m_ForeignAgentsAllowed = serverConfig.GetBoolean("ForeignAgentsAllowed", true); 120 m_ForeignAgentsAllowed = serverConfig.GetBoolean("ForeignAgentsAllowed", true);
115 121
122 LoadDomainExceptionsFromConfig(serverConfig, "AllowExcept", m_ForeignsAllowedExceptions);
123 LoadDomainExceptionsFromConfig(serverConfig, "DisallowExcept", m_ForeignsDisallowedExceptions);
124
116 if (m_GridService == null || m_PresenceService == null || m_SimulationService == null) 125 if (m_GridService == null || m_PresenceService == null || m_SimulationService == null)
117 throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function."); 126 throw new Exception("Unable to load a required plugin, Gatekeeper Service cannot function.");
118 127
@@ -125,6 +134,15 @@ namespace OpenSim.Services.HypergridService
125 { 134 {
126 } 135 }
127 136
137 protected void LoadDomainExceptionsFromConfig(IConfig config, string variable, List<string> exceptions)
138 {
139 string value = config.GetString(variable, string.Empty);
140 string[] parts = value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
141
142 foreach (string s in parts)
143 exceptions.Add(s.Trim());
144 }
145
128 public bool LinkRegion(string regionName, out UUID regionID, out ulong regionHandle, out string externalName, out string imageURL, out string reason) 146 public bool LinkRegion(string regionName, out UUID regionID, out ulong regionHandle, out string externalName, out string imageURL, out string reason)
129 { 147 {
130 regionID = UUID.Zero; 148 regionID = UUID.Zero;
@@ -260,17 +278,26 @@ namespace OpenSim.Services.HypergridService
260 m_log.DebugFormat("[GATEKEEPER SERVICE]: User is ok"); 278 m_log.DebugFormat("[GATEKEEPER SERVICE]: User is ok");
261 279
262 // 280 //
263 // Foreign agents allowed 281 // Foreign agents allowed? Exceptions?
264 // 282 //
265 if (account == null && !m_ForeignAgentsAllowed) 283 if (account == null)
266 { 284 {
267 reason = "Unauthorized"; 285 bool allowed = m_ForeignAgentsAllowed;
268 m_log.InfoFormat("[GATEKEEPER SERVICE]: Foreign agents are not permitted {0} {1}. Refusing service.", 286
269 aCircuit.firstname, aCircuit.lastname); 287 if (m_ForeignAgentsAllowed && IsException(aCircuit, m_ForeignsAllowedExceptions))
270 return false; 288 allowed = false;
271 }
272 289
273 // May want to authorize 290 if (!m_ForeignAgentsAllowed && IsException(aCircuit, m_ForeignsDisallowedExceptions))
291 allowed = true;
292
293 if (!allowed)
294 {
295 reason = "Destination does not allow visitors from your world";
296 m_log.InfoFormat("[GATEKEEPER SERVICE]: Foreign agents are not permitted {0} {1} @ {2}. Refusing service.",
297 aCircuit.firstname, aCircuit.lastname, aCircuit.ServiceURLs["HomeURI"]);
298 return false;
299 }
300 }
274 301
275 bool isFirstLogin = false; 302 bool isFirstLogin = false;
276 // 303 //
@@ -280,7 +307,8 @@ namespace OpenSim.Services.HypergridService
280 if (presence != null) // it has been placed there by the login service 307 if (presence != null) // it has been placed there by the login service
281 isFirstLogin = true; 308 isFirstLogin = true;
282 309
283 else 310 else
311 {
284 if (!m_PresenceService.LoginAgent(aCircuit.AgentID.ToString(), aCircuit.SessionID, aCircuit.SecureSessionID)) 312 if (!m_PresenceService.LoginAgent(aCircuit.AgentID.ToString(), aCircuit.SessionID, aCircuit.SecureSessionID))
285 { 313 {
286 reason = "Unable to login presence"; 314 reason = "Unable to login presence";
@@ -290,6 +318,26 @@ namespace OpenSim.Services.HypergridService
290 } 318 }
291 m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence ok"); 319 m_log.DebugFormat("[GATEKEEPER SERVICE]: Login presence ok");
292 320
321 // Also login foreigners with GridUser service
322 if (m_GridUserService != null && account == null)
323 {
324 string userId = aCircuit.AgentID.ToString();
325 string first = aCircuit.firstname, last = aCircuit.lastname;
326 if (last.StartsWith("@"))
327 {
328 string[] parts = aCircuit.firstname.Split('.');
329 if (parts.Length >= 2)
330 {
331 first = parts[0];
332 last = parts[1];
333 }
334 }
335
336 userId += ";" + aCircuit.ServiceURLs["HomeURI"] + ";" + first + " " + last;
337 m_GridUserService.LoggedIn(userId);
338 }
339 }
340
293 // 341 //
294 // Get the region 342 // Get the region
295 // 343 //
@@ -393,6 +441,27 @@ namespace OpenSim.Services.HypergridService
393 441
394 #region Misc 442 #region Misc
395 443
444 private bool IsException(AgentCircuitData aCircuit, List<string> exceptions)
445 {
446 bool exception = false;
447 if (exceptions.Count > 0) // we have exceptions
448 {
449 // Retrieve the visitor's origin
450 string userURL = aCircuit.ServiceURLs["HomeURI"].ToString();
451 if (!userURL.EndsWith("/"))
452 userURL += "/";
453
454 if (exceptions.Find(delegate(string s)
455 {
456 if (!s.EndsWith("/"))
457 s += "/";
458 return s == userURL;
459 }) != null)
460 exception = true;
461 }
462
463 return exception;
464 }
396 465
397 #endregion 466 #endregion
398 } 467 }