aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorlbsa712008-11-25 11:44:31 +0000
committerlbsa712008-11-25 11:44:31 +0000
commit4cfa8b0a10406e5d046821b2a3ae5e6dbda67a6f (patch)
tree8d99f602ddf8d04d2dc6ac4fb8b00898efb1077a /OpenSim
parentWIP: Adding a few things to PresenceModule. Not quite finished yet. (diff)
downloadopensim-SC_OLD-4cfa8b0a10406e5d046821b2a3ae5e6dbda67a6f.zip
opensim-SC_OLD-4cfa8b0a10406e5d046821b2a3ae5e6dbda67a6f.tar.gz
opensim-SC_OLD-4cfa8b0a10406e5d046821b2a3ae5e6dbda67a6f.tar.bz2
opensim-SC_OLD-4cfa8b0a10406e5d046821b2a3ae5e6dbda67a6f.tar.xz
* First step in refactoring the login code - extracting the authentication
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Communications/LoginService.cs92
1 files changed, 49 insertions, 43 deletions
diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs
index b4ee069..8199598 100644
--- a/OpenSim/Framework/Communications/LoginService.cs
+++ b/OpenSim/Framework/Communications/LoginService.cs
@@ -117,7 +117,8 @@ namespace OpenSim.Framework.Communications
117 117
118 bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && 118 bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") &&
119 (requestData.Contains("passwd") || requestData.Contains("web_login_key"))); 119 (requestData.Contains("passwd") || requestData.Contains("web_login_key")));
120 bool GoodLogin = false; 120
121 bool GoodLogin;
121 122
122 string startLocationRequest = "last"; 123 string startLocationRequest = "last";
123 124
@@ -129,7 +130,12 @@ namespace OpenSim.Framework.Communications
129 130
130 if (GoodXML) 131 if (GoodXML)
131 { 132 {
132 firstname = (string) requestData["first"]; 133 if (requestData.Contains("start"))
134 {
135 startLocationRequest = (string)requestData["start"];
136 }
137
138 firstname = (string)requestData["first"];
133 lastname = (string) requestData["last"]; 139 lastname = (string) requestData["last"];
134 140
135 m_log.InfoFormat( 141 m_log.InfoFormat(
@@ -143,45 +149,13 @@ namespace OpenSim.Framework.Communications
143 clientVersion = (string)requestData["version"]; 149 clientVersion = (string)requestData["version"];
144 } 150 }
145 151
146 if (requestData.Contains("start"))
147 {
148 startLocationRequest = (string)requestData["start"];
149 }
150
151 m_log.DebugFormat( 152 m_log.DebugFormat(
152 "[LOGIN]: XMLRPC Client is {0}, start location is {1}", clientVersion, startLocationRequest); 153 "[LOGIN]: XMLRPC Client is {0}, start location is {1}", clientVersion, startLocationRequest);
153 154
154 userProfile = GetTheUser(firstname, lastname); 155 if( !TryAuthenticateUser(request, firstname, lastname, out userProfile ) )
155 if (userProfile == null)
156 { 156 {
157 m_log.Info("[LOGIN END]: XMLRPC Could not find a profile for " + firstname + " " + lastname);
158
159 return logResponse.CreateLoginFailedResponse(); 157 return logResponse.CreateLoginFailedResponse();
160 } 158 }
161
162 if (requestData.Contains("passwd"))
163 {
164 string passwd = (string)requestData["passwd"];
165 GoodLogin = AuthenticateUser(userProfile, passwd);
166 }
167 else if (requestData.Contains("web_login_key"))
168 {
169 UUID webloginkey;
170 try
171 {
172 webloginkey = new UUID((string)requestData["web_login_key"]);
173 }
174 catch (Exception e)
175 {
176 m_log.InfoFormat(
177 "[LOGIN END]: XMLRPC Bad web_login_key: {0} for user {1} {2}, exception {3}",
178 requestData["web_login_key"], firstname, lastname, e);
179
180 return logResponse.CreateFailedResponse();
181 }
182 GoodLogin = AuthenticateUser(userProfile, webloginkey);
183
184 }
185 } 159 }
186 else 160 else
187 { 161 {
@@ -191,13 +165,7 @@ namespace OpenSim.Framework.Communications
191 return logResponse.CreateGridErrorResponse(); 165 return logResponse.CreateGridErrorResponse();
192 } 166 }
193 167
194 if (!GoodLogin) 168 if (userProfile.GodLevel < m_minLoginLevel)
195 {
196 m_log.InfoFormat("[LOGIN END]: XMLRPC User {0} {1} failed authentication", firstname, lastname);
197
198 return logResponse.CreateLoginFailedResponse();
199 }
200 else if (userProfile.GodLevel < m_minLoginLevel)
201 { 169 {
202 return logResponse.CreateLoginBlockedResponse(); 170 return logResponse.CreateLoginBlockedResponse();
203 } 171 }
@@ -303,7 +271,8 @@ namespace OpenSim.Framework.Communications
303 } 271 }
304 catch (Exception e) 272 catch (Exception e)
305 { 273 {
306 m_log.Info("[LOGIN END]: XMLRPC Login failed, " + e); 274 m_log.Error("[LOGIN END]: XMLRPC Login failed, " + e);
275 m_log.Error(e.StackTrace);
307 } 276 }
308 } 277 }
309 278
@@ -316,6 +285,43 @@ namespace OpenSim.Framework.Communications
316 } 285 }
317 } 286 }
318 287
288 protected virtual bool TryAuthenticateUser(XmlRpcRequest request, string firstname, string lastname, out UserProfileData userProfile)
289 {
290 Hashtable requestData = (Hashtable)request.Params[0];
291
292 bool GoodLogin = false;
293
294 userProfile = GetTheUser(firstname, lastname);
295 if (userProfile == null)
296 {
297 m_log.Info("[LOGIN END]: XMLRPC Could not find a profile for " + firstname + " " + lastname);
298 }
299 else
300 {
301 if (requestData.Contains("passwd"))
302 {
303 string passwd = (string) requestData["passwd"];
304 GoodLogin = AuthenticateUser(userProfile, passwd);
305 }
306 else if (requestData.Contains("web_login_key"))
307 {
308 try
309 {
310 UUID webloginkey = new UUID((string) requestData["web_login_key"]);
311 GoodLogin = AuthenticateUser(userProfile, webloginkey);
312 }
313 catch (Exception e)
314 {
315 m_log.InfoFormat(
316 "[LOGIN END]: XMLRPC Bad web_login_key: {0} for user {1} {2}, exception {3}",
317 requestData["web_login_key"], firstname, lastname, e);
318 }
319 }
320 }
321
322 return GoodLogin;
323 }
324
319 /// <summary> 325 /// <summary>
320 /// Called when we receive the client's initial LLSD login_to_simulator request message 326 /// Called when we receive the client's initial LLSD login_to_simulator request message
321 /// </summary> 327 /// </summary>