diff options
-rw-r--r-- | OpenSim/Framework/UserConfig.cs | 32 | ||||
-rw-r--r-- | OpenSim/Grid/UserServer.Modules/UserLoginAuthService.cs | 223 | ||||
-rw-r--r-- | OpenSim/Grid/UserServer/Main.cs | 8 |
3 files changed, 261 insertions, 2 deletions
diff --git a/OpenSim/Framework/UserConfig.cs b/OpenSim/Framework/UserConfig.cs index 901b57a..ea2cba0 100644 --- a/OpenSim/Framework/UserConfig.cs +++ b/OpenSim/Framework/UserConfig.cs | |||
@@ -64,6 +64,19 @@ namespace OpenSim.Framework | |||
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 | ||
67 | private Uri m_authUrl; | ||
68 | public Uri AuthUrl | ||
69 | { | ||
70 | get | ||
71 | { | ||
72 | return m_authUrl; | ||
73 | } | ||
74 | set | ||
75 | { | ||
76 | m_authUrl = value; | ||
77 | } | ||
78 | } | ||
79 | |||
67 | private Uri m_gridServerURL; | 80 | private Uri m_gridServerURL; |
68 | 81 | ||
69 | public Uri GridServerURL | 82 | public Uri GridServerURL |
@@ -80,6 +93,8 @@ namespace OpenSim.Framework | |||
80 | 93 | ||
81 | public bool EnableLLSDLogin = true; | 94 | public bool EnableLLSDLogin = true; |
82 | 95 | ||
96 | public bool EnableHGLogin = true; | ||
97 | |||
83 | public UserConfig() | 98 | public UserConfig() |
84 | { | 99 | { |
85 | // weird, but UserManagerBase needs this. | 100 | // weird, but UserManagerBase needs this. |
@@ -111,6 +126,11 @@ namespace OpenSim.Framework | |||
111 | "Default Inventory Server URI", | 126 | "Default Inventory Server URI", |
112 | "http://127.0.0.1:" + InventoryConfig.DefaultHttpPort + "/", | 127 | "http://127.0.0.1:" + InventoryConfig.DefaultHttpPort + "/", |
113 | false); | 128 | false); |
129 | configMember.addConfigurationOption("default_authentication_server", | ||
130 | ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | ||
131 | "User Server (this) External URI for authentication keys", | ||
132 | "http://localhost:" + UserConfig.DefaultHttpPort + "/", | ||
133 | false); | ||
114 | configMember.addConfigurationOption("library_location", | 134 | configMember.addConfigurationOption("library_location", |
115 | ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | 135 | ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, |
116 | "Path to library control file", | 136 | "Path to library control file", |
@@ -131,7 +151,10 @@ namespace OpenSim.Framework | |||
131 | "Known good region Y", "1000", false); | 151 | "Known good region Y", "1000", false); |
132 | configMember.addConfigurationOption("enable_llsd_login", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, | 152 | configMember.addConfigurationOption("enable_llsd_login", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, |
133 | "Enable LLSD login support [Currently used by libsl based clients/bots]? true/false", true.ToString(), false); | 153 | "Enable LLSD login support [Currently used by libsl based clients/bots]? true/false", true.ToString(), false); |
134 | 154 | ||
155 | configMember.addConfigurationOption("enable_hg_login", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, | ||
156 | "Enable Hypergrid login support [Currently used by GridSurfer-proxied clients]? true/false", true.ToString(), false); | ||
157 | |||
135 | configMember.addConfigurationOption("default_loginLevel", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, | 158 | configMember.addConfigurationOption("default_loginLevel", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, |
136 | "Minimum Level a user should have to login [0 default]", "0", false); | 159 | "Minimum Level a user should have to login [0 default]", "0", false); |
137 | 160 | ||
@@ -156,6 +179,9 @@ namespace OpenSim.Framework | |||
156 | case "default_inventory_server": | 179 | case "default_inventory_server": |
157 | InventoryUrl = new Uri((string) configuration_result); | 180 | InventoryUrl = new Uri((string) configuration_result); |
158 | break; | 181 | break; |
182 | case "default_authentication_server": | ||
183 | AuthUrl = new Uri((string)configuration_result); | ||
184 | break; | ||
159 | case "database_provider": | 185 | case "database_provider": |
160 | DatabaseProvider = (string) configuration_result; | 186 | DatabaseProvider = (string) configuration_result; |
161 | break; | 187 | break; |
@@ -177,7 +203,9 @@ namespace OpenSim.Framework | |||
177 | case "enable_llsd_login": | 203 | case "enable_llsd_login": |
178 | EnableLLSDLogin = (bool)configuration_result; | 204 | EnableLLSDLogin = (bool)configuration_result; |
179 | break; | 205 | break; |
180 | 206 | case "enable_hg_login": | |
207 | EnableHGLogin = (bool)configuration_result; | ||
208 | break; | ||
181 | case "default_loginLevel": | 209 | case "default_loginLevel": |
182 | DefaultUserLevel = (uint)configuration_result; | 210 | DefaultUserLevel = (uint)configuration_result; |
183 | break; | 211 | break; |
diff --git a/OpenSim/Grid/UserServer.Modules/UserLoginAuthService.cs b/OpenSim/Grid/UserServer.Modules/UserLoginAuthService.cs new file mode 100644 index 0000000..774b4e1 --- /dev/null +++ b/OpenSim/Grid/UserServer.Modules/UserLoginAuthService.cs | |||
@@ -0,0 +1,223 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | using System.Text.RegularExpressions; | ||
33 | using log4net; | ||
34 | using Nwc.XmlRpc; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Data; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Framework.Communications; | ||
39 | using OpenSim.Framework.Communications.Cache; | ||
40 | using OpenSim.Framework.Communications.Capabilities; | ||
41 | using OpenSim.Framework.Servers; | ||
42 | |||
43 | namespace OpenSim.Grid.UserServer.Modules | ||
44 | { | ||
45 | |||
46 | /// <summary> | ||
47 | /// Hypergrid login service used in grid mode. | ||
48 | /// </summary> | ||
49 | public class UserLoginAuthService : HGLoginAuthService | ||
50 | { | ||
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | |||
53 | public UserConfig m_config; | ||
54 | private readonly IRegionProfileRouter m_regionProfileService; | ||
55 | |||
56 | protected BaseHttpServer m_httpServer; | ||
57 | |||
58 | public UserLoginAuthService( | ||
59 | UserManagerBase userManager, IInterServiceInventoryServices inventoryService, | ||
60 | LibraryRootFolder libraryRootFolder, | ||
61 | UserConfig config, string welcomeMess, IRegionProfileRouter regionProfileService) | ||
62 | : base(userManager, welcomeMess, inventoryService, null, true, libraryRootFolder, null) | ||
63 | { | ||
64 | m_config = config; | ||
65 | m_defaultHomeX = m_config.DefaultX; | ||
66 | m_defaultHomeY = m_config.DefaultY; | ||
67 | m_inventoryService = inventoryService; | ||
68 | m_regionProfileService = regionProfileService; | ||
69 | |||
70 | NetworkServersInfo serversinfo = new NetworkServersInfo(1000, 1000); | ||
71 | serversinfo.GridRecvKey = m_config.GridRecvKey; | ||
72 | serversinfo.GridSendKey = m_config.GridSendKey; | ||
73 | serversinfo.GridURL = m_config.GridServerURL.ToString(); | ||
74 | serversinfo.InventoryURL = m_config.InventoryUrl.ToString(); | ||
75 | serversinfo.UserURL = m_config.AuthUrl.ToString(); | ||
76 | SetServersInfo(serversinfo); | ||
77 | } | ||
78 | |||
79 | public void RegisterHandlers(BaseHttpServer httpServer) | ||
80 | { | ||
81 | m_httpServer = httpServer; | ||
82 | |||
83 | httpServer.AddXmlRPCHandler("hg_login", XmlRpcLoginMethod); | ||
84 | httpServer.AddXmlRPCHandler("hg_new_auth_key", XmlRpcGenerateKeyMethod); | ||
85 | httpServer.AddXmlRPCHandler("hg_verify_auth_key", XmlRpcVerifyKeyMethod); | ||
86 | } | ||
87 | |||
88 | |||
89 | public override void LogOffUser(UserProfileData theUser, string message) | ||
90 | { | ||
91 | RegionProfileData SimInfo; | ||
92 | try | ||
93 | { | ||
94 | SimInfo = m_regionProfileService.RequestSimProfileData( | ||
95 | theUser.CurrentAgent.Handle, m_config.GridServerURL, | ||
96 | m_config.GridSendKey, m_config.GridRecvKey); | ||
97 | |||
98 | if (SimInfo == null) | ||
99 | { | ||
100 | m_log.Error("[GRID]: Region user was in isn't currently logged in"); | ||
101 | return; | ||
102 | } | ||
103 | } | ||
104 | catch (Exception) | ||
105 | { | ||
106 | m_log.Error("[GRID]: Unable to look up region to log user off"); | ||
107 | return; | ||
108 | } | ||
109 | |||
110 | // Prepare notification | ||
111 | Hashtable SimParams = new Hashtable(); | ||
112 | SimParams["agent_id"] = theUser.ID.ToString(); | ||
113 | SimParams["region_secret"] = theUser.CurrentAgent.SecureSessionID.ToString(); | ||
114 | SimParams["region_secret2"] = SimInfo.regionSecret; | ||
115 | //m_log.Info(SimInfo.regionSecret); | ||
116 | SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString(); | ||
117 | SimParams["message"] = message; | ||
118 | ArrayList SendParams = new ArrayList(); | ||
119 | SendParams.Add(SimParams); | ||
120 | |||
121 | m_log.InfoFormat( | ||
122 | "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}", | ||
123 | SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI, | ||
124 | theUser.FirstName + " " + theUser.SurName); | ||
125 | |||
126 | try | ||
127 | { | ||
128 | XmlRpcRequest GridReq = new XmlRpcRequest("logoff_user", SendParams); | ||
129 | XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); | ||
130 | |||
131 | if (GridResp.IsFault) | ||
132 | { | ||
133 | m_log.ErrorFormat( | ||
134 | "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.", | ||
135 | SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString); | ||
136 | } | ||
137 | } | ||
138 | catch (Exception) | ||
139 | { | ||
140 | m_log.Error("[LOGIN]: Error telling region to logout user!"); | ||
141 | } | ||
142 | |||
143 | // Prepare notification | ||
144 | SimParams = new Hashtable(); | ||
145 | SimParams["agent_id"] = theUser.ID.ToString(); | ||
146 | SimParams["region_secret"] = SimInfo.regionSecret; | ||
147 | //m_log.Info(SimInfo.regionSecret); | ||
148 | SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString(); | ||
149 | SimParams["message"] = message; | ||
150 | SendParams = new ArrayList(); | ||
151 | SendParams.Add(SimParams); | ||
152 | |||
153 | m_log.InfoFormat( | ||
154 | "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}", | ||
155 | SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI, | ||
156 | theUser.FirstName + " " + theUser.SurName); | ||
157 | |||
158 | try | ||
159 | { | ||
160 | XmlRpcRequest GridReq = new XmlRpcRequest("logoff_user", SendParams); | ||
161 | XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); | ||
162 | |||
163 | if (GridResp.IsFault) | ||
164 | { | ||
165 | m_log.ErrorFormat( | ||
166 | "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.", | ||
167 | SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString); | ||
168 | } | ||
169 | } | ||
170 | catch (Exception) | ||
171 | { | ||
172 | m_log.Error("[LOGIN]: Error telling region to logout user!"); | ||
173 | } | ||
174 | //base.LogOffUser(theUser); | ||
175 | } | ||
176 | |||
177 | protected override RegionInfo RequestClosestRegion(string region) | ||
178 | { | ||
179 | RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(region, | ||
180 | m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); | ||
181 | |||
182 | if (profileData != null) | ||
183 | { | ||
184 | return profileData.ToRegionInfo(); | ||
185 | } | ||
186 | else | ||
187 | { | ||
188 | return null; | ||
189 | } | ||
190 | } | ||
191 | |||
192 | protected override RegionInfo GetRegionInfo(ulong homeRegionHandle) | ||
193 | { | ||
194 | RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(homeRegionHandle, | ||
195 | m_config.GridServerURL, m_config.GridSendKey, | ||
196 | m_config.GridRecvKey); | ||
197 | if (profileData != null) | ||
198 | { | ||
199 | return profileData.ToRegionInfo(); | ||
200 | } | ||
201 | else | ||
202 | { | ||
203 | return null; | ||
204 | } | ||
205 | } | ||
206 | |||
207 | protected override RegionInfo GetRegionInfo(UUID homeRegionId) | ||
208 | { | ||
209 | RegionProfileData profileData = m_regionProfileService.RequestSimProfileData(homeRegionId, | ||
210 | m_config.GridServerURL, m_config.GridSendKey, | ||
211 | m_config.GridRecvKey); | ||
212 | if (profileData != null) | ||
213 | { | ||
214 | return profileData.ToRegionInfo(); | ||
215 | } | ||
216 | else | ||
217 | { | ||
218 | return null; | ||
219 | } | ||
220 | } | ||
221 | |||
222 | } | ||
223 | } | ||
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 5a1dfd1..c0cba4a 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs | |||
@@ -62,6 +62,7 @@ namespace OpenSim.Grid.UserServer | |||
62 | protected UserServerFriendsModule m_friendsModule; | 62 | protected UserServerFriendsModule m_friendsModule; |
63 | 63 | ||
64 | public UserLoginService m_loginService; | 64 | public UserLoginService m_loginService; |
65 | public UserLoginAuthService m_loginAuthService; | ||
65 | public MessageServersConnector m_messagesService; | 66 | public MessageServersConnector m_messagesService; |
66 | 67 | ||
67 | protected GridInfoServiceModule m_gridInfoService; | 68 | protected GridInfoServiceModule m_gridInfoService; |
@@ -191,6 +192,10 @@ namespace OpenSim.Grid.UserServer | |||
191 | { | 192 | { |
192 | m_loginService = new UserLoginService( | 193 | m_loginService = new UserLoginService( |
193 | m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy()); | 194 | m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy()); |
195 | |||
196 | if (Cfg.EnableHGLogin) | ||
197 | m_loginAuthService = new UserLoginAuthService(m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), | ||
198 | Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy()); | ||
194 | } | 199 | } |
195 | 200 | ||
196 | protected virtual void PostInitialiseModules() | 201 | protected virtual void PostInitialiseModules() |
@@ -209,6 +214,9 @@ namespace OpenSim.Grid.UserServer | |||
209 | { | 214 | { |
210 | m_loginService.RegisterHandlers(m_httpServer, Cfg.EnableLLSDLogin, true); | 215 | m_loginService.RegisterHandlers(m_httpServer, Cfg.EnableLLSDLogin, true); |
211 | 216 | ||
217 | if (m_loginAuthService != null) | ||
218 | m_loginAuthService.RegisterHandlers(m_httpServer); | ||
219 | |||
212 | m_userManager.RegisterHandlers(m_httpServer); | 220 | m_userManager.RegisterHandlers(m_httpServer); |
213 | m_friendsModule.RegisterHandlers(m_httpServer); | 221 | m_friendsModule.RegisterHandlers(m_httpServer); |
214 | m_avatarAppearanceModule.RegisterHandlers(m_httpServer); | 222 | m_avatarAppearanceModule.RegisterHandlers(m_httpServer); |