From ff9da2446583ffd95b42e7ced2a86c2166c993c1 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 23 May 2014 17:31:39 -0700 Subject: Added HTTP Authentication also to Groups and offline IM. --- .../Groups/Remote/GroupsServiceRemoteConnector.cs | 33 ++++++++++++++++------ 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnector.cs') 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; using System.Text; using OpenSim.Framework; +using OpenSim.Framework.ServiceAuth; using OpenSim.Server.Base; using OpenMetaverse; using log4net; +using Nini.Config; namespace OpenSim.Groups { - public class GroupsServiceRemoteConnector + public class GroupsServiceRemoteConnector { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private string m_ServerURI; - private string m_SecretKey; + private IServiceAuth m_Auth; private object m_Lock = new object(); - public GroupsServiceRemoteConnector(string url, string secret) + public GroupsServiceRemoteConnector(IConfigSource config) { + IConfig groupsConfig = config.Configs["Groups"]; + string url = groupsConfig.GetString("GroupsServerURI", string.Empty); + if (!Uri.IsWellFormedUriString(url, UriKind.Absolute)) + throw new Exception(string.Format("[Groups.RemoteConnector]: Malformed groups server URL {0}. Fix it or disable the Groups feature.", url)); + m_ServerURI = url; if (!m_ServerURI.EndsWith("/")) m_ServerURI += "/"; - m_SecretKey = secret; - m_log.DebugFormat("[Groups.RemoteConnector]: Groups server at {0}, secret key {1}", m_ServerURI, m_SecretKey); + /// This is from BaseServiceConnector + string authType = Util.GetConfigVarFromSections(config, "AuthType", new string[] { "Network", "Groups" }, "None"); + + switch (authType) + { + case "BasicHttpAuthentication": + m_Auth = new BasicHttpAuthentication(config, "Groups"); + break; + } + /// + + m_log.DebugFormat("[Groups.RemoteConnector]: Groups server at {0}, authentication {1}", + m_ServerURI, (m_Auth == null ? "None" : m_Auth.GetType().ToString())); } public ExtendedGroupRecord CreateGroup(string RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, @@ -656,14 +674,13 @@ namespace OpenSim.Groups private Dictionary MakeRequest(string method, Dictionary sendData) { sendData["METHOD"] = method; - if (m_SecretKey != string.Empty) - sendData["KEY"] = m_SecretKey; string reply = string.Empty; lock (m_Lock) reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "groups", - ServerUtils.BuildQueryString(sendData)); + ServerUtils.BuildQueryString(sendData), + m_Auth); if (reply == string.Empty) return null; -- cgit v1.1