Pass the first name and last name from the agent circuit data to the authorization service rather than from the account.

This is to accomodate situations where the authorization service is being used by the hypergrid, where visitors have no user account.
See http://opensimulator.org/mantis/view.php?id=5517, this code is somewhat adapted/cleaned up from Michelle's patch
I'm a little ambivalent about this since visitors could put anything in firstname/lastname so it's not much of an auth measure.
It's up to the auth service to decide which data it actually uses.
Possibly we should be passing through other info such as agent circuit ip
bulletsim
Justin Clark-Casey (justincc) 2011-07-23 03:46:55 +01:00
parent ea58aee338
commit 504de8bc47
7 changed files with 50 additions and 37 deletions

View File

@ -59,7 +59,7 @@ namespace OpenSim.Framework
clone.Add(uuid, (TaskInventoryItem) this[uuid].Clone()); clone.Add(uuid, (TaskInventoryItem) this[uuid].Clone());
} }
} }
return clone; return clone;
} }

View File

@ -39,8 +39,7 @@ using OpenMetaverse;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
{ {
public class LocalAuthorizationServicesConnector : public class LocalAuthorizationServicesConnector : ISharedRegionModule, IAuthorizationService
ISharedRegionModule, IAuthorizationService
{ {
private static readonly ILog m_log = private static readonly ILog m_log =
LogManager.GetLogger( LogManager.GetLogger(
@ -127,15 +126,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
if (!m_Enabled) if (!m_Enabled)
return; return;
m_log.InfoFormat("[AUTHORIZATION CONNECTOR]: Enabled local authorization for region {0}", scene.RegionInfo.RegionName); m_log.InfoFormat(
"[AUTHORIZATION CONNECTOR]: Enabled local authorization for region {0}",
scene.RegionInfo.RegionName);
} }
public bool IsAuthorizedForRegion(string userID, string regionID, out string message) public bool IsAuthorizedForRegion(
string userID, string firstName, string lastName, string regionID, out string message)
{ {
return m_AuthorizationService.IsAuthorizedForRegion(userID, regionID, out message); return m_AuthorizationService.IsAuthorizedForRegion(userID, firstName, lastName, regionID, out message);
} }
} }
} }

View File

@ -117,12 +117,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
} }
public bool IsAuthorizedForRegion(string userID, string regionID, out string message) public bool IsAuthorizedForRegion(
string userID, string firstName, string lastName, string regionID, out string message)
{ {
m_log.InfoFormat("[REMOTE AUTHORIZATION CONNECTOR]: IsAuthorizedForRegion checking {0} for region {1}", userID, regionID); m_log.InfoFormat(
"[REMOTE AUTHORIZATION CONNECTOR]: IsAuthorizedForRegion checking {0} for region {1}", userID, regionID);
bool isAuthorized = true; bool isAuthorized = true;
message = String.Empty; message = String.Empty;
string mail = String.Empty;
// get the scene this call is being made for // get the scene this call is being made for
Scene scene = null; Scene scene = null;
@ -140,17 +143,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
if (scene != null) if (scene != null)
{ {
UserAccount account = scene.UserAccountService.GetUserAccount(UUID.Zero, new UUID(userID)); UserAccount account = scene.UserAccountService.GetUserAccount(UUID.Zero, new UUID(userID));
isAuthorized = IsAuthorizedForRegion(userID, account.FirstName, account.LastName,
account.Email, scene.RegionInfo.RegionName, regionID, out message); if (account != null)
mail = account.Email;
isAuthorized
= IsAuthorizedForRegion(
userID, firstName, lastName, account.Email, scene.RegionInfo.RegionName, regionID, out message);
} }
else else
{ {
m_log.ErrorFormat("[REMOTE AUTHORIZATION CONNECTOR] IsAuthorizedForRegion, can't find scene to match region id of {0} ",regionID); m_log.ErrorFormat(
"[REMOTE AUTHORIZATION CONNECTOR] IsAuthorizedForRegion, can't find scene to match region id of {0}",
regionID);
} }
return isAuthorized; return isAuthorized;
} }
} }
} }

View File

@ -3553,11 +3553,12 @@ namespace OpenSim.Region.Framework.Scenes
if (AuthorizationService != null) if (AuthorizationService != null)
{ {
if (!AuthorizationService.IsAuthorizedForRegion(agent.AgentID.ToString(), RegionInfo.RegionID.ToString(),out reason)) if (!AuthorizationService.IsAuthorizedForRegion(
agent.AgentID.ToString(), agent.firstname, agent.lastname, RegionInfo.RegionID.ToString(), out reason))
{ {
m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region",
agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
//reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName);
return false; return false;
} }
} }

View File

@ -61,7 +61,7 @@ namespace OpenSim.Server.Handlers.Authorization
AuthorizationRequest Authorization = (AuthorizationRequest) xs.Deserialize(request); AuthorizationRequest Authorization = (AuthorizationRequest) xs.Deserialize(request);
string message = String.Empty; string message = String.Empty;
bool authorized = m_AuthorizationService.IsAuthorizedForRegion(Authorization.ID, Authorization.RegionID,out message); bool authorized = m_AuthorizationService.IsAuthorizedForRegion(Authorization.ID, Authorization.FirstName, Authorization.SurName, Authorization.RegionID, out message);
AuthorizationResponse result = new AuthorizationResponse(authorized, Authorization.ID + " has been authorized"); AuthorizationResponse result = new AuthorizationResponse(authorized, Authorization.ID + " has been authorized");

View File

@ -48,10 +48,11 @@ namespace OpenSim.Services.AuthorizationService
m_log.Info("[AUTHORIZATION CONNECTOR]: Local Authorization service enabled"); m_log.Info("[AUTHORIZATION CONNECTOR]: Local Authorization service enabled");
} }
public bool IsAuthorizedForRegion(string userID, string regionID, out string message) public bool IsAuthorizedForRegion(
string userID, string firstName, string lastName, string regionID, out string message)
{ {
message = "Authorized"; message = "Authorized";
return true; return true;
} }
} }
} }

View File

@ -34,14 +34,21 @@ namespace OpenSim.Services.Interfaces
public interface IAuthorizationService public interface IAuthorizationService
{ {
////////////////////////////////////////////////////// /// <summary>
// Authorized /// Check whether the user should be given access to the region.
// /// </summary>
// This method returns a simple true false indicating /// <remarks>
// whether or not a user has access to the region /// We also supply user first name and last name for situations where the user does not have an account
// /// on the region (e.g. they're a visitor via Hypergrid).
bool IsAuthorizedForRegion(string userID, string regionID, out string message); /// </remarks>
/// <param name="userID"></param>
/// <param name="firstName">/param>
/// <param name="lastName"></param>
/// <param name="regionID"></param>
/// <param name="message"></param>
/// <returns></returns>
bool IsAuthorizedForRegion(
string userID, string firstName, string lastName, string regionID, out string message);
} }
public class AuthorizationRequest public class AuthorizationRequest
@ -63,7 +70,8 @@ namespace OpenSim.Services.Interfaces
m_regionID = RegionID; m_regionID = RegionID;
} }
public AuthorizationRequest(string ID,string FirstName, string SurName, string Email, string RegionName, string RegionID) public AuthorizationRequest(
string ID, string FirstName, string SurName, string Email, string RegionName, string RegionID)
{ {
m_userID = ID; m_userID = ID;
m_firstname = FirstName; m_firstname = FirstName;
@ -108,9 +116,6 @@ namespace OpenSim.Services.Interfaces
get { return m_regionID; } get { return m_regionID; }
set { m_regionID = value; } set { m_regionID = value; }
} }
} }
public class AuthorizationResponse public class AuthorizationResponse
@ -126,7 +131,6 @@ namespace OpenSim.Services.Interfaces
{ {
m_isAuthorized = isAuthorized; m_isAuthorized = isAuthorized;
m_message = message; m_message = message;
} }
public bool IsAuthorized public bool IsAuthorized
@ -141,4 +145,4 @@ namespace OpenSim.Services.Interfaces
set { m_message = value; } set { m_message = value; }
} }
} }
} }