aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs
diff options
context:
space:
mode:
authorDiva Canto2014-05-03 17:13:53 -0700
committerDiva Canto2014-05-03 17:13:53 -0700
commit5a10da3ee89934e366c1d69833b81605dbc35017 (patch)
tree051ee28028598bc8e37e0008bd824cc6689a659b /OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs
parentMantis 7144 missing ATTACH_AVATAR_CENTER constant (diff)
downloadopensim-SC_OLD-5a10da3ee89934e366c1d69833b81605dbc35017.zip
opensim-SC_OLD-5a10da3ee89934e366c1d69833b81605dbc35017.tar.gz
opensim-SC_OLD-5a10da3ee89934e366c1d69833b81605dbc35017.tar.bz2
opensim-SC_OLD-5a10da3ee89934e366c1d69833b81605dbc35017.tar.xz
Added a optional key between the group remote connectors, sim and service. This allows for more secure group services, to be used by collections of mutually-trusting grids.
Diffstat (limited to '')
-rw-r--r--OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs38
1 files changed, 36 insertions, 2 deletions
diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs
index 616afa9..828965f 100644
--- a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs
+++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs
@@ -52,14 +52,24 @@ namespace OpenSim.Groups
52 public GroupsServiceRobustConnector(IConfigSource config, IHttpServer server, string configName) : 52 public GroupsServiceRobustConnector(IConfigSource config, IHttpServer server, string configName) :
53 base(config, server, configName) 53 base(config, server, configName)
54 { 54 {
55 string key = string.Empty;
55 if (configName != String.Empty) 56 if (configName != String.Empty)
56 m_ConfigName = configName; 57 m_ConfigName = configName;
57 58
58 m_log.DebugFormat("[Groups.RobustConnector]: Starting with config name {0}", m_ConfigName); 59 m_log.DebugFormat("[Groups.RobustConnector]: Starting with config name {0}", m_ConfigName);
59 60
61 IConfig groupsConfig = config.Configs[m_ConfigName];
62 if (groupsConfig != null)
63 {
64 key = groupsConfig.GetString("SecretKey", string.Empty);
65 m_log.DebugFormat("[Groups.RobustConnector]: Starting with secret key {0}", key);
66 }
67 else
68 m_log.WarnFormat("[Groups.RobustConnector]: Unable to find {0} section in configuration", m_ConfigName);
69
60 m_GroupsService = new GroupsService(config); 70 m_GroupsService = new GroupsService(config);
61 71
62 server.AddStreamHandler(new GroupsServicePostHandler(m_GroupsService)); 72 server.AddStreamHandler(new GroupsServicePostHandler(m_GroupsService, key));
63 } 73 }
64 } 74 }
65 75
@@ -68,11 +78,13 @@ namespace OpenSim.Groups
68 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 78 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
69 79
70 private GroupsService m_GroupsService; 80 private GroupsService m_GroupsService;
81 private string m_SecretKey = String.Empty;
71 82
72 public GroupsServicePostHandler(GroupsService service) : 83 public GroupsServicePostHandler(GroupsService service, string key) :
73 base("POST", "/groups") 84 base("POST", "/groups")
74 { 85 {
75 m_GroupsService = service; 86 m_GroupsService = service;
87 m_SecretKey = key;
76 } 88 }
77 89
78 protected override byte[] ProcessRequest(string path, Stream requestData, 90 protected override byte[] ProcessRequest(string path, Stream requestData,
@@ -96,6 +108,20 @@ namespace OpenSim.Groups
96 string method = request["METHOD"].ToString(); 108 string method = request["METHOD"].ToString();
97 request.Remove("METHOD"); 109 request.Remove("METHOD");
98 110
111 if (!String.IsNullOrEmpty(m_SecretKey)) // Verification required
112 {
113 // Sender didn't send key
114 if (!request.ContainsKey("KEY") || (request["KEY"] == null))
115 return FailureResult("This service requires a secret key");
116
117 // Sender sent wrong key
118 if (!m_SecretKey.Equals(request["KEY"]))
119 return FailureResult("Provided key does not match existing one");
120
121 // OK, key matches. Remove it.
122 request.Remove("KEY");
123 }
124
99 m_log.DebugFormat("[Groups.Handler]: {0}", method); 125 m_log.DebugFormat("[Groups.Handler]: {0}", method);
100 switch (method) 126 switch (method)
101 { 127 {
@@ -784,6 +810,14 @@ namespace OpenSim.Groups
784 string xmlString = ServerUtils.BuildXmlResponse(result); 810 string xmlString = ServerUtils.BuildXmlResponse(result);
785 return Util.UTF8NoBomEncoding.GetBytes(xmlString); 811 return Util.UTF8NoBomEncoding.GetBytes(xmlString);
786 } 812 }
813
814 private byte[] FailureResult(string reason)
815 {
816 Dictionary<string, object> result = new Dictionary<string, object>();
817 NullResult(result, reason);
818 string xmlString = ServerUtils.BuildXmlResponse(result);
819 return Util.UTF8NoBomEncoding.GetBytes(xmlString);
820 }
787 #endregion 821 #endregion
788 } 822 }
789} 823}