refactoring Scene.NewUserConnection() to be simpler and clearer.
parent
1afdf2ee1f
commit
1352a19838
|
@ -2378,35 +2378,19 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// <param name="reason"></param>
|
/// <param name="reason"></param>
|
||||||
public bool NewUserConnection(AgentCircuitData agent, out string reason)
|
public bool NewUserConnection(AgentCircuitData agent, out string reason)
|
||||||
{
|
{
|
||||||
bool goodUserConnection = AuthenticateUser(agent);
|
// Don't disable this log message - it's too helpful
|
||||||
|
m_log.InfoFormat(
|
||||||
|
"[CONNECTION BEGIN]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5})",
|
||||||
|
RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname,
|
||||||
|
agent.AgentID, agent.circuitcode);
|
||||||
|
|
||||||
reason = String.Empty;
|
reason = String.Empty;
|
||||||
|
if (!AuthenticateUser(agent, out reason))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (goodUserConnection &&
|
if (!AuthorizeUser(agent, out reason))
|
||||||
m_regInfo.EstateSettings.IsBanned(agent.AgentID) &&
|
return false;
|
||||||
(!Permissions.IsGod(agent.AgentID)))
|
|
||||||
{
|
|
||||||
m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
|
|
||||||
agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
|
|
||||||
reason = String.Format("Denied access to region {0}: You have been banned from that region.",
|
|
||||||
RegionInfo.RegionName);
|
|
||||||
goodUserConnection = false;
|
|
||||||
}
|
|
||||||
else if (goodUserConnection &&
|
|
||||||
!m_regInfo.EstateSettings.PublicAccess &&
|
|
||||||
!m_regInfo.EstateSettings.HasAccess(agent.AgentID) &&
|
|
||||||
!Permissions.IsGod(agent.AgentID))
|
|
||||||
{
|
|
||||||
m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access",
|
|
||||||
agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
|
|
||||||
reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
|
|
||||||
RegionInfo.RegionName);
|
|
||||||
goodUserConnection = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (goodUserConnection)
|
|
||||||
{
|
|
||||||
CapsModule.NewUserConnection(agent);
|
CapsModule.NewUserConnection(agent);
|
||||||
|
|
||||||
ScenePresence sp = m_sceneGraph.GetScenePresence(agent.AgentID);
|
ScenePresence sp = m_sceneGraph.GetScenePresence(agent.AgentID);
|
||||||
|
@ -2421,19 +2405,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't disable this log message - it's too helpful
|
|
||||||
m_log.InfoFormat(
|
|
||||||
"[CONNECTION BEGIN]: Region {0} told of incoming client {1} {2} {3} (circuit code {4})",
|
|
||||||
RegionInfo.RegionName, agent.firstname, agent.lastname, agent.AgentID, agent.circuitcode);
|
|
||||||
|
|
||||||
// if (m_regInfo.EstateSettings.IsBanned(agent.AgentID))
|
|
||||||
// {
|
|
||||||
// m_log.WarnFormat(
|
|
||||||
// "[CONNECTION BEGIN]: Incoming user {0} at {1} is on the region banlist",
|
|
||||||
// agent.AgentID, RegionInfo.RegionName);
|
|
||||||
// //return false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
CapsModule.AddCapsHandler(agent.AgentID);
|
CapsModule.AddCapsHandler(agent.AgentID);
|
||||||
|
|
||||||
if (!agent.child)
|
if (!agent.child)
|
||||||
|
@ -2465,25 +2436,47 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
m_log.WarnFormat("[CONNECTION BEGIN]: failed to authenticate user {0} {1}: {2}. Denying connection.",
|
|
||||||
agent.firstname, agent.lastname, reason);
|
|
||||||
if (String.IsNullOrEmpty(reason))
|
|
||||||
{
|
|
||||||
reason = String.Format("Failed to authenticate user {0} {1}, access denied.", agent.firstname, agent.lastname);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual bool AuthenticateUser(AgentCircuitData agent)
|
public virtual bool AuthenticateUser(AgentCircuitData agent, out string reason)
|
||||||
{
|
{
|
||||||
|
reason = String.Empty;
|
||||||
|
|
||||||
bool result = CommsManager.UserService.VerifySession(agent.AgentID, agent.SessionID);
|
bool result = CommsManager.UserService.VerifySession(agent.AgentID, agent.SessionID);
|
||||||
m_log.Debug("[CONNECTION BEGIN]: User authentication returned " + result);
|
m_log.Debug("[CONNECTION BEGIN]: User authentication returned " + result);
|
||||||
|
if (!result)
|
||||||
|
reason = String.Format("Failed to authenticate user {0} {1}, access denied.", agent.firstname, agent.lastname);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual bool AuthorizeUser(AgentCircuitData agent, out string reason)
|
||||||
|
{
|
||||||
|
reason = String.Empty;
|
||||||
|
|
||||||
|
if (m_regInfo.EstateSettings.IsBanned(agent.AgentID) &&
|
||||||
|
(!Permissions.IsGod(agent.AgentID)))
|
||||||
|
{
|
||||||
|
m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
|
||||||
|
agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
|
||||||
|
reason = String.Format("Denied access to region {0}: You have been banned from that region.",
|
||||||
|
RegionInfo.RegionName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_regInfo.EstateSettings.PublicAccess &&
|
||||||
|
!m_regInfo.EstateSettings.HasAccess(agent.AgentID) &&
|
||||||
|
!Permissions.IsGod(agent.AgentID))
|
||||||
|
{
|
||||||
|
m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access",
|
||||||
|
agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
|
||||||
|
reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
|
||||||
|
RegionInfo.RegionName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public void UpdateCircuitData(AgentCircuitData data)
|
public void UpdateCircuitData(AgentCircuitData data)
|
||||||
{
|
{
|
||||||
m_authenticateHandler.UpdateAgentData(data);
|
m_authenticateHandler.UpdateAgentData(data);
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Communications;
|
using OpenSim.Framework.Communications;
|
||||||
|
@ -55,8 +56,9 @@ namespace OpenSim.Tests.Common.Mock
|
||||||
///
|
///
|
||||||
/// <param name="agent"></param>
|
/// <param name="agent"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override bool AuthenticateUser(AgentCircuitData agent)
|
public override bool AuthenticateUser(AgentCircuitData agent, out string reason)
|
||||||
{
|
{
|
||||||
|
reason = String.Empty;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue