diff options
author | Dr Scofield | 2008-05-19 17:54:31 +0000 |
---|---|---|
committer | Dr Scofield | 2008-05-19 17:54:31 +0000 |
commit | af469631764aa0c7ae8d11a77baec5a78f0c1b3b (patch) | |
tree | 088a4d16a3633e2b721da98f059a686aca7a4511 /OpenSim | |
parent | (from awebb) (diff) | |
download | opensim-SC_OLD-af469631764aa0c7ae8d11a77baec5a78f0c1b3b.zip opensim-SC_OLD-af469631764aa0c7ae8d11a77baec5a78f0c1b3b.tar.gz opensim-SC_OLD-af469631764aa0c7ae8d11a77baec5a78f0c1b3b.tar.bz2 opensim-SC_OLD-af469631764aa0c7ae8d11a77baec5a78f0c1b3b.tar.xz |
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.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/ApplicationPlugins/Rest/RestPlugin.cs | 16 |
1 files changed, 11 insertions, 5 deletions
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 | |||
211 | 211 | ||
212 | // Retrieve GOD key value, if any. | 212 | // Retrieve GOD key value, if any. |
213 | _godkey = _config.GetString("god_key", String.Empty); | 213 | _godkey = _config.GetString("god_key", String.Empty); |
214 | |||
214 | // Retrive prefix if any. | 215 | // Retrive prefix if any. |
215 | _prefix = _config.GetString("prefix", "/admin"); | 216 | _prefix = _config.GetString("prefix", "/admin"); |
216 | 217 | ||
@@ -242,7 +243,7 @@ namespace OpenSim.ApplicationPlugins.Rest | |||
242 | 243 | ||
243 | private List<RestStreamHandler> _handlers = new List<RestStreamHandler>(); | 244 | private List<RestStreamHandler> _handlers = new List<RestStreamHandler>(); |
244 | 245 | ||
245 | public void AddRestStreamHandler(string httpMethod, string path, RestMethod method) | 246 | public virtual void AddRestStreamHandler(string httpMethod, string path, RestMethod method) |
246 | { | 247 | { |
247 | if (!IsEnabled) return; | 248 | if (!IsEnabled) return; |
248 | 249 | ||
@@ -258,13 +259,18 @@ namespace OpenSim.ApplicationPlugins.Rest | |||
258 | m_log.DebugFormat("{0} Added REST handler {1} {2}", MsgID, httpMethod, path); | 259 | m_log.DebugFormat("{0} Added REST handler {1} {2}", MsgID, httpMethod, path); |
259 | } | 260 | } |
260 | 261 | ||
261 | 262 | public bool AddAgentHandler(string agentname, IHttpAgentHandler handler) | |
262 | protected bool VerifyGod(string key) | ||
263 | { | 263 | { |
264 | if (String.IsNullOrEmpty(key)) return false; | ||
265 | if (!IsEnabled) return false; | 264 | if (!IsEnabled) return false; |
265 | return _httpd.AddAgentHandler(agentname, handler); | ||
266 | } | ||
266 | 267 | ||
267 | return key == _godkey; | 268 | protected bool IsGod(OSHttpRequest request) |
269 | { | ||
270 | string[] keys = request.Headers.GetValues("x-opensim-godkey"); | ||
271 | if (null == keys) return false; | ||
272 | // we take the last key supplied | ||
273 | return keys[keys.Length-1] == _godkey; | ||
268 | } | 274 | } |
269 | 275 | ||
270 | public virtual void Close() | 276 | public virtual void Close() |