Quite big change to how Sessions/circuits are Authenticated. Seems to work okay but needs a lot more testing.

This commit is contained in:
MW
2007-05-16 17:35:27 +00:00
parent 6056247ac3
commit 1e9a0220e6
14 changed files with 263 additions and 94 deletions

View File

@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Types;
namespace OpenSim
{
public class AuthenticateSessionsBase
{
private Dictionary<uint, AgentCircuitData> AgentCircuits = new Dictionary<uint, AgentCircuitData>();
public AuthenticateSessionsBase()
{
}
public virtual AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitcode)
{
AgentCircuitData validcircuit = null;
if (this.AgentCircuits.ContainsKey(circuitcode))
{
validcircuit = this.AgentCircuits[circuitcode];
}
AuthenticateResponse user = new AuthenticateResponse();
if (validcircuit == null)
{
//don't have this circuit code in our list
user.Authorised = false;
return (user);
}
if ((sessionID == validcircuit.SessionID) && (agentID == validcircuit.AgentID))
{
user.Authorised = true;
user.LoginInfo = new Login();
user.LoginInfo.Agent = agentID;
user.LoginInfo.Session = sessionID;
user.LoginInfo.SecureSession = validcircuit.SecureSessionID;
user.LoginInfo.First = validcircuit.firstname;
user.LoginInfo.Last = validcircuit.lastname;
user.LoginInfo.InventoryFolder = validcircuit.InventoryFolder;
user.LoginInfo.BaseFolder = validcircuit.BaseFolder;
}
else
{
// Invalid
user.Authorised = false;
}
return (user);
}
public virtual void AddNewCircuit(uint circuitCode, AgentCircuitData agentData)
{
if (this.AgentCircuits.ContainsKey(circuitCode))
{
this.AgentCircuits[circuitCode] = agentData;
}
else
{
this.AgentCircuits.Add(circuitCode, agentData);
}
}
}
}

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Framework.Types;
namespace OpenSim
{
public class AuthenticateSessionsLocal : AuthenticateSessionsBase
{
public AuthenticateSessionsLocal()
{
}
public void AddNewSession(Login loginData)
{
AgentCircuitData agent = new AgentCircuitData();
agent.AgentID = loginData.Agent;
agent.firstname = loginData.First;
agent.lastname = loginData.Last;
agent.SessionID = loginData.Session;
agent.SecureSessionID = loginData.SecureSession;
agent.circuitcode = loginData.CircuitCode;
agent.BaseFolder = loginData.BaseFolder;
agent.InventoryFolder = loginData.InventoryFolder;
this.AddNewCircuit(agent.circuitcode, agent);
}
}
}

View File

@@ -0,0 +1,44 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using libsecondlife;
using OpenSim.Framework.Types;
using Nwc.XmlRpc;
namespace OpenSim
{
public class AuthenticateSessionsRemote : AuthenticateSessionsBase
{
public AuthenticateSessionsRemote()
{
}
public XmlRpcResponse ExpectUser(XmlRpcRequest request)
{
Hashtable requestData = (Hashtable)request.Params[0];
AgentCircuitData agentData = new AgentCircuitData();
agentData.SessionID = new LLUUID((string)requestData["session_id"]);
agentData.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]);
agentData.firstname = (string)requestData["firstname"];
agentData.lastname = (string)requestData["lastname"];
agentData.AgentID = new LLUUID((string)requestData["agent_id"]);
agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1"))
{
agentData.child = true;
}
else
{
agentData.startpos = new LLVector3(Convert.ToUInt32(requestData["startpos_x"]), Convert.ToUInt32(requestData["startpos_y"]), Convert.ToUInt32(requestData["startpos_z"]));
agentData.child = false;
}
this.AddNewCircuit(agentData.circuitcode, agentData);
return new XmlRpcResponse();
}
}
}

View File

@@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
@@ -6,7 +6,8 @@
<ProjectGuid>{632E1BFD-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon></ApplicationIcon>
<ApplicationIcon>
</ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>OpenSim.RegionServer</AssemblyName>
@@ -15,9 +16,11 @@
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<AppDesignerFolder></AppDesignerFolder>
<AppDesignerFolder>
</AppDesignerFolder>
<RootNamespace>OpenSim.RegionServer</RootNamespace>
<StartupObject></StartupObject>
<StartupObject>
</StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
@@ -28,7 +31,8 @@
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile></DocumentationFile>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
@@ -37,7 +41,8 @@
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
<NoWarn>
</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
@@ -46,7 +51,8 @@
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile></DocumentationFile>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
@@ -55,26 +61,28 @@
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
<NoWarn>
</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" >
<Reference Include="System">
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml" >
<Reference Include="System.Data" />
<Reference Include="System.Xml">
<HintPath>System.Xml.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="libsecondlife.dll" >
<Reference Include="libsecondlife.dll">
<HintPath>..\bin\libsecondlife.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Axiom.MathLib.dll" >
<Reference Include="Axiom.MathLib.dll">
<HintPath>..\bin\Axiom.MathLib.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Db4objects.Db4o.dll" >
<Reference Include="Db4objects.Db4o.dll">
<HintPath>..\bin\Db4objects.Db4o.dll</HintPath>
<Private>False</Private>
</Reference>
@@ -84,49 +92,52 @@
<Name>OpenSim.Terrain.BasicTerrain</Name>
<Project>{2270B8FE-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\OpenSim.Framework\OpenSim.Framework.csproj">
<Name>OpenSim.Framework</Name>
<Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
<Name>OpenSim.Framework.Console</Name>
<Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\OpenSim.GenericConfig\Xml\OpenSim.GenericConfig.Xml.csproj">
<Name>OpenSim.GenericConfig.Xml</Name>
<Project>{E88EF749-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\OpenSim.Physics\Manager\OpenSim.Physics.Manager.csproj">
<Name>OpenSim.Physics.Manager</Name>
<Project>{8BE16150-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\OpenSim.Servers\OpenSim.Servers.csproj">
<Name>OpenSim.Servers</Name>
<Project>{8BB20F0A-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\XmlRpcCS\XMLRPC.csproj">
<Name>XMLRPC</Name>
<Project>{8E81D43C-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="AgentAssetUpload.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="AuthenticateSessionsBase.cs" />
<Compile Include="AuthenticateSessionsLocal.cs" />
<Compile Include="AuthenticateSessionsRemote.cs" />
<Compile Include="Grid.cs">
<SubType>Code</SubType>
</Compile>
@@ -150,12 +161,16 @@
</Compile>
<Compile Include="SimClient.Grid.cs">
<SubType>Code</SubType>
<DependentUpon>SimClient.cs</DependentUpon>
</Compile>
<Compile Include="SimClient.PacketHandlers.cs">
<SubType>Code</SubType>
<DependentUpon>SimClient.cs</DependentUpon>
</Compile>
<Compile Include="SimClient.ProcessPackets.cs">
<SubType>Code</SubType>
<DependentUpon>SimClient.cs</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="SimClientBase.cs">
<SubType>Code</SubType>
@@ -183,12 +198,14 @@
</Compile>
<Compile Include="world\Avatar.Client.cs">
<SubType>Code</SubType>
<DependentUpon>Avatar.cs</DependentUpon>
</Compile>
<Compile Include="world\Avatar.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="world\Avatar.Update.cs">
<SubType>Code</SubType>
<DependentUpon>Avatar.cs</DependentUpon>
</Compile>
<Compile Include="world\AvatarAnimations.cs">
<SubType>Code</SubType>
@@ -210,9 +227,11 @@
</Compile>
<Compile Include="world\World.PacketHandlers.cs">
<SubType>Code</SubType>
<DependentUpon>World.cs</DependentUpon>
</Compile>
<Compile Include="world\World.Scripting.cs">
<SubType>Code</SubType>
<DependentUpon>World.cs</DependentUpon>
</Compile>
<Compile Include="world\scripting\IScriptContext.cs">
<SubType>Code</SubType>
@@ -240,4 +259,4 @@
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>
</Project>

View File

@@ -12,6 +12,8 @@
</resources>
<sources failonempty="true">
<include name="AgentAssetUpload.cs" />
<include name="AuthenticateSessionsBase.cs" />
<include name="AuthenticateSessionsLocal.cs" />
<include name="Grid.cs" />
<include name="OpenSimMain.cs" />
<include name="OpenSimNetworkHandler.cs" />

View File

@@ -77,6 +77,7 @@ namespace OpenSim
private UDPServer m_udpServer;
protected BaseHttpServer httpServer;
private AuthenticateSessionsBase AuthenticateSessionsHandler;
protected ConsoleBase m_console;
@@ -144,8 +145,19 @@ namespace OpenSim
Environment.Exit(1);
}
//PacketServer packetServer = new PacketServer(this);
m_udpServer = new UDPServer(this.regionData.IPListenPort, this.GridServers, this.AssetCache, this.InventoryCache, this.regionData, this.m_sandbox, this.user_accounts, this.m_console);
//Authenticate Session Handler
if (m_sandbox)
{
AuthenticateSessionsLocal authen = new AuthenticateSessionsLocal();
this.AuthenticateSessionsHandler = authen;
}
else
{
AuthenticateSessionsRemote authen = new AuthenticateSessionsRemote();
this.AuthenticateSessionsHandler = authen;
}
m_udpServer = new UDPServer(this.regionData.IPListenPort, this.GridServers, this.AssetCache, this.InventoryCache, this.regionData, this.m_sandbox, this.user_accounts, this.m_console, this.AuthenticateSessionsHandler);
//should be passing a IGenericConfig object to these so they can read the config data they want from it
GridServers.AssetServer.SetServerInfo(regionData.AssetURL, regionData.AssetSendKey);
@@ -174,8 +186,9 @@ namespace OpenSim
bool sandBoxWithLoginServer = m_loginserver && m_sandbox;
if (sandBoxWithLoginServer)
{
loginServer = new LoginServer(gridServer, regionData.IPListenAddr, regionData.IPListenPort, regionData.RegionLocX, regionData.RegionLocY, this.user_accounts);
loginServer = new LoginServer( regionData.IPListenAddr, regionData.IPListenPort, regionData.RegionLocX, regionData.RegionLocY, this.user_accounts);
loginServer.Startup();
loginServer.SetSessionHandler(((AuthenticateSessionsLocal) this.AuthenticateSessionsHandler).AddNewSession);
if (user_accounts)
{
@@ -285,38 +298,7 @@ namespace OpenSim
{
// we are in Grid mode so set a XmlRpc handler to handle "expect_user" calls from the user server
httpServer.AddXmlRPCHandler("expect_user",
delegate(XmlRpcRequest request)
{
Hashtable requestData = (Hashtable)request.Params[0];
AgentCircuitData agent_data = new AgentCircuitData();
agent_data.SessionID = new LLUUID((string)requestData["session_id"]);
agent_data.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]);
agent_data.firstname = (string)requestData["firstname"];
agent_data.lastname = (string)requestData["lastname"];
agent_data.AgentID = new LLUUID((string)requestData["agent_id"]);
agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1"))
{
agent_data.child = true;
}
else
{
agent_data.startpos = new LLVector3(Convert.ToUInt32(requestData["startpos_x"]), Convert.ToUInt32(requestData["startpos_y"]), Convert.ToUInt32(requestData["startpos_z"]));
agent_data.child = false;
}
if (((RemoteGridBase)this.GridServers.GridServer).agentcircuits.ContainsKey((uint)agent_data.circuitcode))
{
((RemoteGridBase)this.GridServers.GridServer).agentcircuits[(uint)agent_data.circuitcode] = agent_data;
}
else
{
((RemoteGridBase)this.GridServers.GridServer).agentcircuits.Add((uint)agent_data.circuitcode, agent_data);
}
return new XmlRpcResponse();
});
httpServer.AddXmlRPCHandler("expect_user", ((AuthenticateSessionsRemote)this.AuthenticateSessionsHandler).ExpectUser );
httpServer.AddXmlRPCHandler("agent_crossing",
delegate(XmlRpcRequest request)

View File

@@ -113,14 +113,14 @@ namespace OpenSim
OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "OpenSimClient.cs - Started up new client thread to handle incoming request");
cirpack = initialcirpack;
userEP = remoteEP;
if (m_gridServer.GetName() == "Remote")
/* if (m_gridServer.GetName() == "Remote")
{
this.startpos = ((RemoteGridBase)m_gridServer).agentcircuits[initialcirpack.CircuitCode.Code].startpos;
}
else
{
{*/
this.startpos = new LLVector3(128, 128, m_world.Terrain[(int)128, (int)128] + 15.0f); // new LLVector3(128.0f, 128.0f, 60f);
}
//}
PacketQueue = new BlockingQueue<QueItem>();
this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache);

View File

@@ -47,6 +47,8 @@ namespace OpenSim
private bool m_sandbox = false;
private bool user_accounts = false;
private ConsoleBase m_console;
private AuthenticateSessionsBase m_authenticateSessionsClass;
public AuthenticateSessionHandler AuthenticateHandler;
public PacketServer PacketServer
@@ -70,7 +72,7 @@ namespace OpenSim
}
}
public UDPServer(int port, Grid gridServers, AssetCache assetCache, InventoryCache inventoryCache, RegionInfo _regionData, bool sandbox, bool accounts, ConsoleBase console)
public UDPServer(int port, Grid gridServers, AssetCache assetCache, InventoryCache inventoryCache, RegionInfo _regionData, bool sandbox, bool accounts, ConsoleBase console , AuthenticateSessionsBase authenticateClass)
{
listenPort = port;
this.m_gridServers = gridServers;
@@ -80,10 +82,11 @@ namespace OpenSim
this.m_sandbox = sandbox;
this.user_accounts = accounts;
this.m_console = console;
this.m_authenticateSessionsClass = authenticateClass;
PacketServer packetServer = new PacketServer(this);
//set up delegate for authenticate sessions
this.AuthenticateHandler = new AuthenticateSessionHandler(this.m_gridServers.GridServer.AuthenticateSession);
this.AuthenticateHandler = new AuthenticateSessionHandler(this.m_authenticateSessionsClass.AuthenticateSession);
}
protected virtual void OnReceivedData(IAsyncResult result)