* Added SetPassword to IAuthenticationService.
* Added create user command to UserAccountService. Works. * Deleted create user command from OpenSim.slimupdates
parent
2639fa6ded
commit
96ecdcf9c5
|
@ -349,9 +349,6 @@ namespace OpenSim
|
||||||
|
|
||||||
if (ConfigurationSettings.Standalone)
|
if (ConfigurationSettings.Standalone)
|
||||||
{
|
{
|
||||||
m_console.Commands.AddCommand("region", false, "create user",
|
|
||||||
"create user [<first> [<last> [<pass> [<x> <y> [<email>]]]]]",
|
|
||||||
"Create a new user", HandleCreateUser);
|
|
||||||
|
|
||||||
m_console.Commands.AddCommand("region", false, "reset user password",
|
m_console.Commands.AddCommand("region", false, "reset user password",
|
||||||
"reset user password [<first> [<last> [<password>]]]",
|
"reset user password [<first> [<last> [<password>]]]",
|
||||||
|
@ -812,22 +809,6 @@ namespace OpenSim
|
||||||
m_console.ConsoleScene = m_sceneManager.CurrentScene;
|
m_console.ConsoleScene = m_sceneManager.CurrentScene;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Execute switch for some of the create commands
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="args"></param>
|
|
||||||
private void HandleCreateUser(string module, string[] cmd)
|
|
||||||
{
|
|
||||||
if (ConfigurationSettings.Standalone)
|
|
||||||
{
|
|
||||||
CreateUser(cmd);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_log.Info("Create user is not available in grid mode, use the user server.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Execute switch for some of the reset commands
|
/// Execute switch for some of the reset commands
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1075,61 +1056,6 @@ namespace OpenSim
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create a new user
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email</param>
|
|
||||||
protected void CreateUser(string[] cmdparams)
|
|
||||||
{
|
|
||||||
string firstName;
|
|
||||||
string lastName;
|
|
||||||
string password;
|
|
||||||
string email;
|
|
||||||
uint regX = 1000;
|
|
||||||
uint regY = 1000;
|
|
||||||
|
|
||||||
IConfig standalone;
|
|
||||||
if ((standalone = m_config.Source.Configs["StandAlone"]) != null)
|
|
||||||
{
|
|
||||||
regX = (uint)standalone.GetInt("default_location_x", (int)regX);
|
|
||||||
regY = (uint)standalone.GetInt("default_location_y", (int)regY);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (cmdparams.Length < 3)
|
|
||||||
firstName = MainConsole.Instance.CmdPrompt("First name", "Default");
|
|
||||||
else firstName = cmdparams[2];
|
|
||||||
|
|
||||||
if (cmdparams.Length < 4)
|
|
||||||
lastName = MainConsole.Instance.CmdPrompt("Last name", "User");
|
|
||||||
else lastName = cmdparams[3];
|
|
||||||
|
|
||||||
if (cmdparams.Length < 5)
|
|
||||||
password = MainConsole.Instance.PasswdPrompt("Password");
|
|
||||||
else password = cmdparams[4];
|
|
||||||
|
|
||||||
if (cmdparams.Length < 6)
|
|
||||||
regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString()));
|
|
||||||
else regX = Convert.ToUInt32(cmdparams[5]);
|
|
||||||
|
|
||||||
if (cmdparams.Length < 7)
|
|
||||||
regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString()));
|
|
||||||
else regY = Convert.ToUInt32(cmdparams[6]);
|
|
||||||
|
|
||||||
if (cmdparams.Length < 8)
|
|
||||||
email = MainConsole.Instance.CmdPrompt("Email", "");
|
|
||||||
else email = cmdparams[7];
|
|
||||||
|
|
||||||
if (null == m_commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName))
|
|
||||||
{
|
|
||||||
m_commsManager.UserAdminService.AddUser(firstName, lastName, password, email, regX, regY);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat("[CONSOLE]: A user with the name {0} {1} already exists!", firstName, lastName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reset a user password.
|
/// Reset a user password.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -153,6 +153,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication
|
||||||
return m_AuthenticationService.Release(principalID, token);
|
return m_AuthenticationService.Release(principalID, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool SetPassword(UUID principalID, string passwd)
|
||||||
|
{
|
||||||
|
return m_AuthenticationService.SetPassword(principalID, passwd);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ using Nini.Config;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using OpenSim.Services.Base;
|
using OpenSim.Services.Base;
|
||||||
using OpenSim.Data;
|
using OpenSim.Data;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
|
||||||
namespace OpenSim.Services.AuthenticationService
|
namespace OpenSim.Services.AuthenticationService
|
||||||
{
|
{
|
||||||
|
@ -43,9 +44,9 @@ namespace OpenSim.Services.AuthenticationService
|
||||||
//
|
//
|
||||||
public class AuthenticationServiceBase : ServiceBase
|
public class AuthenticationServiceBase : ServiceBase
|
||||||
{
|
{
|
||||||
// private static readonly ILog m_log =
|
private static readonly ILog m_log =
|
||||||
// LogManager.GetLogger(
|
LogManager.GetLogger(
|
||||||
// MethodBase.GetCurrentMethod().DeclaringType);
|
MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
protected IAuthenticationData m_Database;
|
protected IAuthenticationData m_Database;
|
||||||
|
|
||||||
|
@ -100,6 +101,27 @@ namespace OpenSim.Services.AuthenticationService
|
||||||
return m_Database.CheckToken(principalID, token, 0);
|
return m_Database.CheckToken(principalID, token, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual bool SetPassword(UUID principalID, string password)
|
||||||
|
{
|
||||||
|
string passwordSalt = Util.Md5Hash(UUID.Random().ToString());
|
||||||
|
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + passwordSalt);
|
||||||
|
|
||||||
|
AuthenticationData auth = new AuthenticationData();
|
||||||
|
auth.PrincipalID = principalID;
|
||||||
|
auth.Data = new System.Collections.Generic.Dictionary<string, object>();
|
||||||
|
auth.Data["passwordHash"] = md5PasswdHash;
|
||||||
|
auth.Data["passwordSalt"] = passwordSalt;
|
||||||
|
auth.Data["webLoginKey"] = UUID.Zero.ToString();
|
||||||
|
if (!m_Database.Store(auth))
|
||||||
|
{
|
||||||
|
m_log.DebugFormat("[AUTHENTICATION DB]: Failed to store authentication data");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_log.InfoFormat("[AUTHENTICATION DB]: Set password for principalID {0}", principalID);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
protected string GetToken(UUID principalID, int lifetime)
|
protected string GetToken(UUID principalID, int lifetime)
|
||||||
{
|
{
|
||||||
UUID token = UUID.Random();
|
UUID token = UUID.Random();
|
||||||
|
@ -109,5 +131,6 @@ namespace OpenSim.Services.AuthenticationService
|
||||||
|
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,5 +146,11 @@ namespace OpenSim.Services.Connectors
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool SetPassword(UUID principalID, string passwd)
|
||||||
|
{
|
||||||
|
// nope, we don't do this
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,17 @@ namespace OpenSim.Services.Interfaces
|
||||||
//
|
//
|
||||||
bool Release(UUID principalID, string token);
|
bool Release(UUID principalID, string token);
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// SetPassword for a principal
|
||||||
|
//
|
||||||
|
// This method exists for the service, but may or may not
|
||||||
|
// be served remotely. That is, the authentication
|
||||||
|
// handlers may not include one handler for this,
|
||||||
|
// because it's a bit risky. Such handlers require
|
||||||
|
// authentication/authorization.
|
||||||
|
//
|
||||||
|
bool SetPassword(UUID principalID, string passwd);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
// Grid
|
// Grid
|
||||||
//
|
//
|
||||||
|
|
|
@ -26,25 +26,58 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
using OpenSim.Data;
|
using OpenSim.Data;
|
||||||
using OpenSim.Framework.Console;
|
|
||||||
using OpenSim.Services.Interfaces;
|
using OpenSim.Services.Interfaces;
|
||||||
using System.Collections.Generic;
|
using OpenSim.Framework.Console;
|
||||||
|
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
||||||
|
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
|
using log4net;
|
||||||
|
|
||||||
namespace OpenSim.Services.UserAccountService
|
namespace OpenSim.Services.UserAccountService
|
||||||
{
|
{
|
||||||
public class UserAccountService : UserAccountServiceBase, IUserAccountService
|
public class UserAccountService : UserAccountServiceBase, IUserAccountService
|
||||||
{
|
{
|
||||||
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
private static UserAccountService m_RootInstance;
|
||||||
|
|
||||||
|
protected IGridService m_GridService;
|
||||||
|
protected IAuthenticationService m_AuthenticationService;
|
||||||
|
protected IPresenceService m_PresenceService;
|
||||||
|
|
||||||
public UserAccountService(IConfigSource config)
|
public UserAccountService(IConfigSource config)
|
||||||
: base(config)
|
: base(config)
|
||||||
{
|
{
|
||||||
MainConsole.Instance.Commands.AddCommand("UserService", false,
|
IConfig userConfig = config.Configs["UserAccountService"];
|
||||||
"create user",
|
if (userConfig == null)
|
||||||
"create user [<first> [<last> [<pass> [<x> <y> [<email>]]]]]",
|
throw new Exception("No UserAccountService configuration");
|
||||||
"Create a new user", HandleCreateUser);
|
|
||||||
|
// In case there are several instances of this class in the same process,
|
||||||
|
// the console commands are only registered for the root instance
|
||||||
|
if (m_RootInstance == null)
|
||||||
|
{
|
||||||
|
m_RootInstance = this;
|
||||||
|
string gridServiceDll = userConfig.GetString("GridService", string.Empty);
|
||||||
|
if (gridServiceDll != string.Empty)
|
||||||
|
m_GridService = LoadPlugin<IGridService>(gridServiceDll, new Object[] { config });
|
||||||
|
|
||||||
|
string authServiceDll = userConfig.GetString("AuthenticationService", string.Empty);
|
||||||
|
if (authServiceDll != string.Empty)
|
||||||
|
m_AuthenticationService = LoadPlugin<IAuthenticationService>(authServiceDll, new Object[] { config });
|
||||||
|
|
||||||
|
string presenceServiceDll = userConfig.GetString("PresenceService", string.Empty);
|
||||||
|
if (presenceServiceDll != string.Empty)
|
||||||
|
m_PresenceService = LoadPlugin<IPresenceService>(presenceServiceDll, new Object[] { config });
|
||||||
|
|
||||||
|
MainConsole.Instance.Commands.AddCommand("UserService", false,
|
||||||
|
"create user",
|
||||||
|
"create user [<first> [<last> [<pass> [<email>]]]]",
|
||||||
|
"Create a new user", HandleCreateUser);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IUserAccountService
|
#region IUserAccountService
|
||||||
|
@ -202,52 +235,64 @@ namespace OpenSim.Services.UserAccountService
|
||||||
string lastName;
|
string lastName;
|
||||||
string password;
|
string password;
|
||||||
string email;
|
string email;
|
||||||
uint regX = 1000;
|
|
||||||
uint regY = 1000;
|
|
||||||
|
|
||||||
// IConfig standalone;
|
if (cmdparams.Length < 3)
|
||||||
// if ((standalone = m_config.Source.Configs["StandAlone"]) != null)
|
firstName = MainConsole.Instance.CmdPrompt("First name", "Default");
|
||||||
// {
|
else firstName = cmdparams[2];
|
||||||
// regX = (uint)standalone.GetInt("default_location_x", (int)regX);
|
|
||||||
// regY = (uint)standalone.GetInt("default_location_y", (int)regY);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
if (cmdparams.Length < 4)
|
||||||
|
lastName = MainConsole.Instance.CmdPrompt("Last name", "User");
|
||||||
|
else lastName = cmdparams[3];
|
||||||
|
|
||||||
// if (cmdparams.Length < 3)
|
if (cmdparams.Length < 5)
|
||||||
// firstName = MainConsole.Instance.CmdPrompt("First name", "Default");
|
password = MainConsole.Instance.PasswdPrompt("Password");
|
||||||
// else firstName = cmdparams[2];
|
else password = cmdparams[4];
|
||||||
|
|
||||||
// if (cmdparams.Length < 4)
|
if (cmdparams.Length < 6)
|
||||||
// lastName = MainConsole.Instance.CmdPrompt("Last name", "User");
|
email = MainConsole.Instance.CmdPrompt("Email", "");
|
||||||
// else lastName = cmdparams[3];
|
else email = cmdparams[5];
|
||||||
|
|
||||||
// if (cmdparams.Length < 5)
|
UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName);
|
||||||
// password = MainConsole.Instance.PasswdPrompt("Password");
|
if (null == account)
|
||||||
// else password = cmdparams[4];
|
{
|
||||||
|
account = new UserAccount(UUID.Zero, firstName, lastName, email);
|
||||||
|
if (StoreUserAccount(account))
|
||||||
|
{
|
||||||
|
bool success = false;
|
||||||
|
if (m_AuthenticationService != null)
|
||||||
|
success = m_AuthenticationService.SetPassword(account.PrincipalID, password);
|
||||||
|
if (!success)
|
||||||
|
m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.",
|
||||||
|
firstName, lastName);
|
||||||
|
|
||||||
// if (cmdparams.Length < 6)
|
GridRegion home = null;
|
||||||
// regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString()));
|
if (m_GridService != null)
|
||||||
// else regX = Convert.ToUInt32(cmdparams[5]);
|
{
|
||||||
|
List<GridRegion> defaultRegions = m_GridService.GetDefaultRegions(UUID.Zero);
|
||||||
|
if (defaultRegions != null && defaultRegions.Count >= 1)
|
||||||
|
home = defaultRegions[0];
|
||||||
|
|
||||||
// if (cmdparams.Length < 7)
|
if (m_PresenceService != null && home != null)
|
||||||
// regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString()));
|
m_PresenceService.SetHomeLocation(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0));
|
||||||
// else regY = Convert.ToUInt32(cmdparams[6]);
|
else
|
||||||
|
m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.",
|
||||||
|
firstName, lastName);
|
||||||
|
|
||||||
// if (cmdparams.Length < 8)
|
}
|
||||||
// email = MainConsole.Instance.CmdPrompt("Email", "");
|
else
|
||||||
// else email = cmdparams[7];
|
m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.",
|
||||||
|
firstName, lastName);
|
||||||
|
|
||||||
// if (null == m_commsManager.UserProfileCacheService.GetUserDetails(firstName, lastName))
|
m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", firstName, lastName);
|
||||||
// {
|
}
|
||||||
// m_commsManager.UserAdminService.AddUser(firstName, lastName, password, email, regX, regY);
|
}
|
||||||
// }
|
else
|
||||||
// else
|
{
|
||||||
// {
|
m_log.ErrorFormat("[USER ACCOUNT SERVICE]: A user with the name {0} {1} already exists!", firstName, lastName);
|
||||||
// m_log.ErrorFormat("[CONSOLE]: A user with the name {0} {1} already exists!", firstName, lastName);
|
}
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,11 @@
|
||||||
|
|
||||||
[UserAccountService]
|
[UserAccountService]
|
||||||
LocalServiceModule = "OpenSim.Services.UserAccountService.dll:UserAccountService"
|
LocalServiceModule = "OpenSim.Services.UserAccountService.dll:UserAccountService"
|
||||||
|
;; These are for creating new accounts
|
||||||
|
AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"
|
||||||
|
PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService"
|
||||||
|
GridService = "OpenSim.Services.GridService.dll:GridService"
|
||||||
|
|
||||||
[LoginService]
|
[LoginService]
|
||||||
LocalServiceModule = "OpenSim.Services.LLLoginService.dll:LLLoginService"
|
LocalServiceModule = "OpenSim.Services.LLLoginService.dll:LLLoginService"
|
||||||
UserAccountService = "OpenSim.Services.UserAccountService.dll:UserAccountService"
|
UserAccountService = "OpenSim.Services.UserAccountService.dll:UserAccountService"
|
||||||
|
|
Loading…
Reference in New Issue