aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorEva Comaroski2013-11-17 12:06:32 +0000
committerJustin Clark-Casey (justincc)2013-11-20 00:09:32 +0000
commitc896b4179ebc4bdc89b4373e93f4b04174f0c758 (patch)
tree552b61cc6f04c48bea53b7af721c5b678e22960a /OpenSim
parentFix bug where "show modules" would accidentally list all the shared modules a... (diff)
downloadopensim-SC-c896b4179ebc4bdc89b4373e93f4b04174f0c758.zip
opensim-SC-c896b4179ebc4bdc89b4373e93f4b04174f0c758.tar.gz
opensim-SC-c896b4179ebc4bdc89b4373e93f4b04174f0c758.tar.bz2
opensim-SC-c896b4179ebc4bdc89b4373e93f4b04174f0c758.tar.xz
Added admin_authenticate_user command
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs136
1 files changed, 136 insertions, 0 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index 8b66ee1..354f587 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Globalization;
31using System.IO; 32using System.IO;
32using System.Xml; 33using System.Xml;
33using System.Net; 34using System.Net;
@@ -51,6 +52,7 @@ using OpenSim.Services.Interfaces;
51using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; 52using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
52using GridRegion = OpenSim.Services.Interfaces.GridRegion; 53using GridRegion = OpenSim.Services.Interfaces.GridRegion;
53using PermissionMask = OpenSim.Framework.PermissionMask; 54using PermissionMask = OpenSim.Framework.PermissionMask;
55using RegionInfo = OpenSim.Framework.RegionInfo;
54 56
55namespace OpenSim.ApplicationPlugins.RemoteController 57namespace OpenSim.ApplicationPlugins.RemoteController
56{ 58{
@@ -145,6 +147,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
145 availableMethods["admin_create_user_email"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcCreateUserMethod); 147 availableMethods["admin_create_user_email"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcCreateUserMethod);
146 availableMethods["admin_exists_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcUserExistsMethod); 148 availableMethods["admin_exists_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcUserExistsMethod);
147 availableMethods["admin_update_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcUpdateUserAccountMethod); 149 availableMethods["admin_update_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcUpdateUserAccountMethod);
150 availableMethods["admin_authenticate_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAuthenticateUserMethod);
148 151
149 // Region state management 152 // Region state management
150 availableMethods["admin_load_xml"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadXMLMethod); 153 availableMethods["admin_load_xml"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadXMLMethod);
@@ -1281,6 +1284,139 @@ namespace OpenSim.ApplicationPlugins.RemoteController
1281 } 1284 }
1282 1285
1283 /// <summary> 1286 /// <summary>
1287 /// Authenticate an user.
1288 /// <summary>
1289 /// <param name="request">incoming XML RPC request</param>
1290 /// <remarks>
1291 /// XmlRpcAuthenticateUserMethod takes the following XMLRPC
1292 /// parameters
1293 /// <list type="table">
1294 /// <listheader><term>parameter name</term><description>description</description></listheader>
1295 /// <item><term>password</term>
1296 /// <description>admin password as set in OpenSim.ini</description></item>
1297 /// <item><term>user_firstname</term>
1298 /// <description>avatar's first name</description></item>
1299 /// <item><term>user_lastname</term>
1300 /// <description>avatar's last name</description></item>
1301 /// <item><term>user_password</term>
1302 /// <description>MD5 hash of avatar's password</description></item>
1303 /// <item><term>token_lifetime</term>
1304 /// <description>the lifetime of the returned token (upper bounded to 30s)</description></item>
1305 /// </list>
1306 ///
1307 /// XmlRpcAuthenticateUserMethod returns
1308 /// <list type="table">
1309 /// <listheader><term>name</term><description>description</description></listheader>
1310 /// <item><term>success</term>
1311 /// <description>true or false</description></item>
1312 /// <item><term>token</term>
1313 /// <description>the authentication token sent by OpenSim</description></item>
1314 /// <item><term>error</term>
1315 /// <description>error message if success is false</description></item>
1316 /// </list>
1317 /// </remarks>
1318 private void XmlRpcAuthenticateUserMethod(XmlRpcRequest request, XmlRpcResponse response,
1319 IPEndPoint remoteClient)
1320 {
1321 m_log.Info("[RADMIN]: AuthenticateUser: new request");
1322
1323 var responseData = (Hashtable)response.Value;
1324 var requestData = (Hashtable)request.Params[0];
1325
1326 lock (m_requestLock)
1327 {
1328 try
1329 {
1330 CheckStringParameters(requestData, responseData, new[]
1331 {
1332 "user_firstname",
1333 "user_lastname",
1334 "user_password",
1335 "token_lifetime"
1336 });
1337
1338 var firstName = (string)requestData["user_firstname"];
1339 var lastName = (string)requestData["user_lastname"];
1340 var password = (string)requestData["user_password"];
1341
1342 var scene = m_application.SceneManager.CurrentOrFirstScene;
1343
1344 if (scene.Equals(null))
1345 {
1346 m_log.Debug("scene does not exist");
1347 throw new Exception("Scene does not exist.");
1348 }
1349
1350 var scopeID = scene.RegionInfo.ScopeID;
1351 var account = scene.UserAccountService.GetUserAccount(scopeID, firstName, lastName);
1352
1353 if (account.Equals(null) || account.PrincipalID.Equals(UUID.Zero))
1354 {
1355 m_log.DebugFormat("avatar {0} {1} does not exist", firstName, lastName);
1356 throw new Exception(String.Format("avatar {0} {1} does not exist", firstName, lastName));
1357 }
1358
1359 if (String.IsNullOrEmpty(password))
1360 {
1361 m_log.DebugFormat("[RADMIN]: AuthenticateUser: no password provided for {0} {1}", firstName,
1362 lastName);
1363 throw new Exception(String.Format("no password provided for {0} {1}", firstName,
1364 lastName));
1365 }
1366
1367 int lifetime;
1368 if (int.TryParse((string)requestData["token_lifetime"], NumberStyles.Integer, CultureInfo.InvariantCulture, out lifetime) == false)
1369 {
1370 m_log.DebugFormat("[RADMIN]: AuthenticateUser: no token lifetime provided for {0} {1}", firstName,
1371 lastName);
1372 throw new Exception(String.Format("no token lifetime provided for {0} {1}", firstName,
1373 lastName));
1374 }
1375
1376 // Upper bound on lifetime set to 30s.
1377 if (lifetime > 30)
1378 {
1379 m_log.DebugFormat("[RADMIN]: AuthenticateUser: token lifetime longer than 30s for {0} {1}", firstName,
1380 lastName);
1381 throw new Exception(String.Format("token lifetime longer than 30s for {0} {1}", firstName,
1382 lastName));
1383 }
1384
1385 var authModule = scene.RequestModuleInterface<IAuthenticationService>();
1386 if (authModule == null)
1387 {
1388 m_log.Debug("[RADMIN]: AuthenticateUser: no authentication module loded");
1389 throw new Exception("no authentication module loaded");
1390 }
1391
1392 var token = authModule.Authenticate(account.PrincipalID, password, lifetime);
1393 if (String.IsNullOrEmpty(token))
1394 {
1395 m_log.DebugFormat("[RADMIN]: AuthenticateUser: authentication failed for {0} {1}", firstName,
1396 lastName);
1397 throw new Exception(String.Format("authentication failed for {0} {1}", firstName,
1398 lastName));
1399 }
1400
1401 m_log.DebugFormat("[RADMIN]: AuthenticateUser: account for user {0} {1} identified with token {2}",
1402 firstName, lastName, token);
1403
1404 responseData["token"] = token;
1405 responseData["success"] = true;
1406
1407 }
1408 catch (Exception e)
1409 {
1410 responseData["success"] = false;
1411 responseData["error"] = e.Message;
1412 throw e;
1413 }
1414
1415 m_log.Info("[RADMIN]: AuthenticateUser: request complete");
1416 }
1417 }
1418
1419 /// <summary>
1284 /// Load an OAR file into a region.. 1420 /// Load an OAR file into a region..
1285 /// <summary> 1421 /// <summary>
1286 /// <param name="request">incoming XML RPC request</param> 1422 /// <param name="request">incoming XML RPC request</param>