From af469631764aa0c7ae8d11a77baec5a78f0c1b3b Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Mon, 19 May 2008 17:54:31 +0000 Subject: i'm dropping VerifyGod() and adding IsGod(OSHttpRequest) instead, which actually now takes a look at the HTTP request header and retrieves x-opensim-godkey (if it exists) and compares that against the godkey from OpenSim.ini. also, this makes AddStreamHandler() virtual so that it can be overridden. --- OpenSim/ApplicationPlugins/Rest/RestPlugin.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs b/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs index 199bff8..8c370ed 100644 --- a/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs +++ b/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs @@ -211,6 +211,7 @@ namespace OpenSim.ApplicationPlugins.Rest // Retrieve GOD key value, if any. _godkey = _config.GetString("god_key", String.Empty); + // Retrive prefix if any. _prefix = _config.GetString("prefix", "/admin"); @@ -242,7 +243,7 @@ namespace OpenSim.ApplicationPlugins.Rest private List _handlers = new List(); - public void AddRestStreamHandler(string httpMethod, string path, RestMethod method) + public virtual void AddRestStreamHandler(string httpMethod, string path, RestMethod method) { if (!IsEnabled) return; @@ -258,13 +259,18 @@ namespace OpenSim.ApplicationPlugins.Rest m_log.DebugFormat("{0} Added REST handler {1} {2}", MsgID, httpMethod, path); } - - protected bool VerifyGod(string key) + public bool AddAgentHandler(string agentname, IHttpAgentHandler handler) { - if (String.IsNullOrEmpty(key)) return false; if (!IsEnabled) return false; + return _httpd.AddAgentHandler(agentname, handler); + } - return key == _godkey; + protected bool IsGod(OSHttpRequest request) + { + string[] keys = request.Headers.GetValues("x-opensim-godkey"); + if (null == keys) return false; + // we take the last key supplied + return keys[keys.Length-1] == _godkey; } public virtual void Close() -- cgit v1.1