From eda09d87635683d92d1661f6bbedf678c879c08f Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 16 Mar 2015 23:40:34 +0000 Subject: [PATCH] Fix XBakes simulator-side authentication regression failure Unlike the other connectors, XBakes uses a service auth retrieved from ServiceAuth.Create() and not code inherited from BaseServiceConnector. Fixes regression from 7d3bafd5 (Wed 4 Mar 2015) where the new CompoundAuthenticator did not implement IServiceAuth.AddAuthorization() --- .../ServiceAuth/BasicHttpAuthentication.cs | 2 ++ .../Framework/ServiceAuth/CompoundAuthentication.cs | 13 ++++++++++++- .../Framework/ServiceAuth/DisallowLlHttpRequest.cs | 2 ++ OpenSim/Framework/ServiceAuth/IServiceAuth.cs | 7 ++++++- OpenSim/Framework/ServiceAuth/ServiceAuth.cs | 8 +++++++- 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs b/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs index 3c13bbf82f..b20f8f5b88 100644 --- a/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs +++ b/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs @@ -40,6 +40,8 @@ namespace OpenSim.Framework.ServiceAuth { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public string Name { get { return "BasicHttp"; } } + private string m_Username, m_Password; private string m_CredentialsB64; diff --git a/OpenSim/Framework/ServiceAuth/CompoundAuthentication.cs b/OpenSim/Framework/ServiceAuth/CompoundAuthentication.cs index 8c88d1c50f..a49952c513 100644 --- a/OpenSim/Framework/ServiceAuth/CompoundAuthentication.cs +++ b/OpenSim/Framework/ServiceAuth/CompoundAuthentication.cs @@ -35,10 +35,17 @@ namespace OpenSim.Framework.ServiceAuth { public class CompoundAuthentication : IServiceAuth { + public string Name { get { return "Compound"; } } + private List m_authentications = new List(); public int Count { get { return m_authentications.Count; } } + public List GetAuthentors() + { + return new List(m_authentications); + } + public void AddAuthenticator(IServiceAuth auth) { m_authentications.Add(auth); @@ -49,7 +56,11 @@ namespace OpenSim.Framework.ServiceAuth m_authentications.Remove(auth); } - public void AddAuthorization(NameValueCollection headers) {} + public void AddAuthorization(NameValueCollection headers) + { + foreach (IServiceAuth auth in m_authentications) + auth.AddAuthorization(headers); + } public bool Authenticate(string data) { diff --git a/OpenSim/Framework/ServiceAuth/DisallowLlHttpRequest.cs b/OpenSim/Framework/ServiceAuth/DisallowLlHttpRequest.cs index 1e1ee562e9..e0c413bac9 100644 --- a/OpenSim/Framework/ServiceAuth/DisallowLlHttpRequest.cs +++ b/OpenSim/Framework/ServiceAuth/DisallowLlHttpRequest.cs @@ -33,6 +33,8 @@ namespace OpenSim.Framework.ServiceAuth { public class DisallowLlHttpRequest : IServiceAuth { + public string Name { get { return "DisallowllHTTPRequest"; } } + public void AddAuthorization(NameValueCollection headers) {} public bool Authenticate(string data) diff --git a/OpenSim/Framework/ServiceAuth/IServiceAuth.cs b/OpenSim/Framework/ServiceAuth/IServiceAuth.cs index adde62f8c1..5f744cbe10 100644 --- a/OpenSim/Framework/ServiceAuth/IServiceAuth.cs +++ b/OpenSim/Framework/ServiceAuth/IServiceAuth.cs @@ -34,8 +34,13 @@ namespace OpenSim.Framework.ServiceAuth { public delegate void AddHeaderDelegate(string key, string value); - public interface IServiceAuth + public interface IServiceAuth { + /// + /// Name of this authenticator. + /// + string Name { get; } + bool Authenticate(string data); bool Authenticate(NameValueCollection headers, AddHeaderDelegate d, out HttpStatusCode statusCode); void AddAuthorization(NameValueCollection headers); diff --git a/OpenSim/Framework/ServiceAuth/ServiceAuth.cs b/OpenSim/Framework/ServiceAuth/ServiceAuth.cs index 30f5bd61f0..51012e3450 100644 --- a/OpenSim/Framework/ServiceAuth/ServiceAuth.cs +++ b/OpenSim/Framework/ServiceAuth/ServiceAuth.cs @@ -27,13 +27,16 @@ using System; using System.Collections.Generic; - +using System.Reflection; +using log4net; using Nini.Config; namespace OpenSim.Framework.ServiceAuth { public class ServiceAuth { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public static IServiceAuth Create(IConfigSource config, string section) { CompoundAuthentication compoundAuth = new CompoundAuthentication(); @@ -53,6 +56,9 @@ namespace OpenSim.Framework.ServiceAuth break; } +// foreach (IServiceAuth auth in compoundAuth.GetAuthentors()) +// m_log.DebugFormat("[SERVICE AUTH]: Configured authenticator {0}", auth.Name); + if (compoundAuth.Count > 0) return compoundAuth; else