diff options
author | Diva Canto | 2014-05-23 17:31:39 -0700 |
---|---|---|
committer | Diva Canto | 2014-05-23 17:31:39 -0700 |
commit | ff9da2446583ffd95b42e7ced2a86c2166c993c1 (patch) | |
tree | b775be9cce73a03831bd7d4c23555d844874c093 /OpenSim/Addons/Groups | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-ff9da2446583ffd95b42e7ced2a86c2166c993c1.zip opensim-SC_OLD-ff9da2446583ffd95b42e7ced2a86c2166c993c1.tar.gz opensim-SC_OLD-ff9da2446583ffd95b42e7ced2a86c2166c993c1.tar.bz2 opensim-SC_OLD-ff9da2446583ffd95b42e7ced2a86c2166c993c1.tar.xz |
Added HTTP Authentication also to Groups and offline IM.
Diffstat (limited to 'OpenSim/Addons/Groups')
3 files changed, 32 insertions, 34 deletions
diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs index 1425a23..7450c14 100644 --- a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs +++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs | |||
@@ -32,29 +32,47 @@ using System.Reflection; | |||
32 | using System.Text; | 32 | using System.Text; |
33 | 33 | ||
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.ServiceAuth; | ||
35 | using OpenSim.Server.Base; | 36 | using OpenSim.Server.Base; |
36 | 37 | ||
37 | using OpenMetaverse; | 38 | using OpenMetaverse; |
38 | using log4net; | 39 | using log4net; |
40 | using Nini.Config; | ||
39 | 41 | ||
40 | namespace OpenSim.Groups | 42 | namespace OpenSim.Groups |
41 | { | 43 | { |
42 | public class GroupsServiceRemoteConnector | 44 | public class GroupsServiceRemoteConnector |
43 | { | 45 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 47 | ||
46 | private string m_ServerURI; | 48 | private string m_ServerURI; |
47 | private string m_SecretKey; | 49 | private IServiceAuth m_Auth; |
48 | private object m_Lock = new object(); | 50 | private object m_Lock = new object(); |
49 | 51 | ||
50 | public GroupsServiceRemoteConnector(string url, string secret) | 52 | public GroupsServiceRemoteConnector(IConfigSource config) |
51 | { | 53 | { |
54 | IConfig groupsConfig = config.Configs["Groups"]; | ||
55 | string url = groupsConfig.GetString("GroupsServerURI", string.Empty); | ||
56 | if (!Uri.IsWellFormedUriString(url, UriKind.Absolute)) | ||
57 | throw new Exception(string.Format("[Groups.RemoteConnector]: Malformed groups server URL {0}. Fix it or disable the Groups feature.", url)); | ||
58 | |||
52 | m_ServerURI = url; | 59 | m_ServerURI = url; |
53 | if (!m_ServerURI.EndsWith("/")) | 60 | if (!m_ServerURI.EndsWith("/")) |
54 | m_ServerURI += "/"; | 61 | m_ServerURI += "/"; |
55 | 62 | ||
56 | m_SecretKey = secret; | 63 | /// This is from BaseServiceConnector |
57 | m_log.DebugFormat("[Groups.RemoteConnector]: Groups server at {0}, secret key {1}", m_ServerURI, m_SecretKey); | 64 | string authType = Util.GetConfigVarFromSections<string>(config, "AuthType", new string[] { "Network", "Groups" }, "None"); |
65 | |||
66 | switch (authType) | ||
67 | { | ||
68 | case "BasicHttpAuthentication": | ||
69 | m_Auth = new BasicHttpAuthentication(config, "Groups"); | ||
70 | break; | ||
71 | } | ||
72 | /// | ||
73 | |||
74 | m_log.DebugFormat("[Groups.RemoteConnector]: Groups server at {0}, authentication {1}", | ||
75 | m_ServerURI, (m_Auth == null ? "None" : m_Auth.GetType().ToString())); | ||
58 | } | 76 | } |
59 | 77 | ||
60 | public ExtendedGroupRecord CreateGroup(string RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, | 78 | public ExtendedGroupRecord CreateGroup(string RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, |
@@ -656,14 +674,13 @@ namespace OpenSim.Groups | |||
656 | private Dictionary<string, object> MakeRequest(string method, Dictionary<string, object> sendData) | 674 | private Dictionary<string, object> MakeRequest(string method, Dictionary<string, object> sendData) |
657 | { | 675 | { |
658 | sendData["METHOD"] = method; | 676 | sendData["METHOD"] = method; |
659 | if (m_SecretKey != string.Empty) | ||
660 | sendData["KEY"] = m_SecretKey; | ||
661 | 677 | ||
662 | string reply = string.Empty; | 678 | string reply = string.Empty; |
663 | lock (m_Lock) | 679 | lock (m_Lock) |
664 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | 680 | reply = SynchronousRestFormsRequester.MakeRequest("POST", |
665 | m_ServerURI + "groups", | 681 | m_ServerURI + "groups", |
666 | ServerUtils.BuildQueryString(sendData)); | 682 | ServerUtils.BuildQueryString(sendData), |
683 | m_Auth); | ||
667 | 684 | ||
668 | if (reply == string.Empty) | 685 | if (reply == string.Empty) |
669 | return null; | 686 | return null; |
diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs index 5fb3c19..fddda22 100644 --- a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs +++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs | |||
@@ -72,13 +72,7 @@ namespace OpenSim.Groups | |||
72 | 72 | ||
73 | private void Init(IConfigSource config) | 73 | private void Init(IConfigSource config) |
74 | { | 74 | { |
75 | IConfig groupsConfig = config.Configs["Groups"]; | 75 | m_GroupsService = new GroupsServiceRemoteConnector(config); |
76 | string url = groupsConfig.GetString("GroupsServerURI", string.Empty); | ||
77 | if (!Uri.IsWellFormedUriString(url, UriKind.Absolute)) | ||
78 | throw new Exception(string.Format("[Groups.RemoteConnector]: Malformed groups server URL {0}. Fix it or disable the Groups feature.", url)); | ||
79 | |||
80 | string secret = groupsConfig.GetString("SecretKey", string.Empty); | ||
81 | m_GroupsService = new GroupsServiceRemoteConnector(url, secret); | ||
82 | m_Scenes = new List<Scene>(); | 76 | m_Scenes = new List<Scene>(); |
83 | 77 | ||
84 | } | 78 | } |
diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs index 33dc301..55ae6db 100644 --- a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs +++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs | |||
@@ -36,6 +36,7 @@ using OpenSim.Framework; | |||
36 | using OpenSim.Server.Base; | 36 | using OpenSim.Server.Base; |
37 | using OpenSim.Services.Interfaces; | 37 | using OpenSim.Services.Interfaces; |
38 | using OpenSim.Framework.Servers.HttpServer; | 38 | using OpenSim.Framework.Servers.HttpServer; |
39 | using OpenSim.Framework.ServiceAuth; | ||
39 | using OpenSim.Server.Handlers.Base; | 40 | using OpenSim.Server.Handlers.Base; |
40 | using log4net; | 41 | using log4net; |
41 | using OpenMetaverse; | 42 | using OpenMetaverse; |
@@ -69,7 +70,9 @@ namespace OpenSim.Groups | |||
69 | 70 | ||
70 | m_GroupsService = new GroupsService(config); | 71 | m_GroupsService = new GroupsService(config); |
71 | 72 | ||
72 | server.AddStreamHandler(new GroupsServicePostHandler(m_GroupsService, key)); | 73 | IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); |
74 | |||
75 | server.AddStreamHandler(new GroupsServicePostHandler(m_GroupsService, auth)); | ||
73 | } | 76 | } |
74 | } | 77 | } |
75 | 78 | ||
@@ -78,13 +81,11 @@ namespace OpenSim.Groups | |||
78 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 81 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
79 | 82 | ||
80 | private GroupsService m_GroupsService; | 83 | private GroupsService m_GroupsService; |
81 | private string m_SecretKey = String.Empty; | ||
82 | 84 | ||
83 | public GroupsServicePostHandler(GroupsService service, string key) : | 85 | public GroupsServicePostHandler(GroupsService service, IServiceAuth auth) : |
84 | base("POST", "/groups") | 86 | base("POST", "/groups", auth) |
85 | { | 87 | { |
86 | m_GroupsService = service; | 88 | m_GroupsService = service; |
87 | m_SecretKey = key; | ||
88 | } | 89 | } |
89 | 90 | ||
90 | protected override byte[] ProcessRequest(string path, Stream requestData, | 91 | protected override byte[] ProcessRequest(string path, Stream requestData, |
@@ -108,20 +109,6 @@ namespace OpenSim.Groups | |||
108 | string method = request["METHOD"].ToString(); | 109 | string method = request["METHOD"].ToString(); |
109 | request.Remove("METHOD"); | 110 | request.Remove("METHOD"); |
110 | 111 | ||
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 | |||
125 | m_log.DebugFormat("[Groups.Handler]: {0}", method); | 112 | m_log.DebugFormat("[Groups.Handler]: {0}", method); |
126 | switch (method) | 113 | switch (method) |
127 | { | 114 | { |