diff options
author | Diva Canto | 2010-01-10 17:15:02 -0800 |
---|---|---|
committer | Diva Canto | 2010-01-10 17:15:02 -0800 |
commit | b0bbe861cd0f3eb06de73a371ab961428c549c69 (patch) | |
tree | 67110bb96bf3dfd6b0236f75761db5327adc515e /OpenSim/Grid/UserServer.Modules/OpenIdService.cs | |
parent | Forgot to remove 'using' (diff) | |
download | opensim-SC_OLD-b0bbe861cd0f3eb06de73a371ab961428c549c69.zip opensim-SC_OLD-b0bbe861cd0f3eb06de73a371ab961428c549c69.tar.gz opensim-SC_OLD-b0bbe861cd0f3eb06de73a371ab961428c549c69.tar.bz2 opensim-SC_OLD-b0bbe861cd0f3eb06de73a371ab961428c549c69.tar.xz |
Moved OpenId authentication from user server to Server.Handlers.Authentication.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs (renamed from OpenSim/Grid/UserServer.Modules/OpenIdService.cs) | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/OpenSim/Grid/UserServer.Modules/OpenIdService.cs b/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs index 49dfd86..e73961b 100644 --- a/OpenSim/Grid/UserServer.Modules/OpenIdService.cs +++ b/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs | |||
@@ -36,8 +36,12 @@ using DotNetOpenId.Provider; | |||
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Servers; | 37 | using OpenSim.Framework.Servers; |
38 | using OpenSim.Framework.Servers.HttpServer; | 38 | using OpenSim.Framework.Servers.HttpServer; |
39 | using OpenSim.Server.Handlers.Base; | ||
40 | using OpenSim.Services.Interfaces; | ||
41 | using Nini.Config; | ||
42 | using OpenMetaverse; | ||
39 | 43 | ||
40 | namespace OpenSim.Grid.UserServer.Modules | 44 | namespace OpenSim.Server.Handlers.Authentication |
41 | { | 45 | { |
42 | /// <summary> | 46 | /// <summary> |
43 | /// Temporary, in-memory store for OpenID associations | 47 | /// Temporary, in-memory store for OpenID associations |
@@ -194,15 +198,17 @@ For more information, see <a href='http://openid.net/'>http://openid.net/</a>. | |||
194 | string m_contentType; | 198 | string m_contentType; |
195 | string m_httpMethod; | 199 | string m_httpMethod; |
196 | string m_path; | 200 | string m_path; |
197 | UserLoginService m_loginService; | 201 | IAuthenticationService m_authenticationService; |
202 | IUserAccountService m_userAccountService; | ||
198 | ProviderMemoryStore m_openidStore = new ProviderMemoryStore(); | 203 | ProviderMemoryStore m_openidStore = new ProviderMemoryStore(); |
199 | 204 | ||
200 | /// <summary> | 205 | /// <summary> |
201 | /// Constructor | 206 | /// Constructor |
202 | /// </summary> | 207 | /// </summary> |
203 | public OpenIdStreamHandler(string httpMethod, string path, UserLoginService loginService) | 208 | public OpenIdStreamHandler(string httpMethod, string path, IUserAccountService userService, IAuthenticationService authService) |
204 | { | 209 | { |
205 | m_loginService = loginService; | 210 | m_authenticationService = authService; |
211 | m_userAccountService = userService; | ||
206 | m_httpMethod = httpMethod; | 212 | m_httpMethod = httpMethod; |
207 | m_path = path; | 213 | m_path = path; |
208 | 214 | ||
@@ -235,13 +241,14 @@ For more information, see <a href='http://openid.net/'>http://openid.net/</a>. | |||
235 | IAuthenticationRequest authRequest = (IAuthenticationRequest)provider.Request; | 241 | IAuthenticationRequest authRequest = (IAuthenticationRequest)provider.Request; |
236 | string[] passwordValues = postQuery.GetValues("pass"); | 242 | string[] passwordValues = postQuery.GetValues("pass"); |
237 | 243 | ||
238 | UserProfileData profile; | 244 | UserAccount account; |
239 | if (TryGetProfile(new Uri(authRequest.ClaimedIdentifier.ToString()), out profile)) | 245 | if (TryGetAccount(new Uri(authRequest.ClaimedIdentifier.ToString()), out account)) |
240 | { | 246 | { |
241 | // Check for form POST data | 247 | // Check for form POST data |
242 | if (passwordValues != null && passwordValues.Length == 1) | 248 | if (passwordValues != null && passwordValues.Length == 1) |
243 | { | 249 | { |
244 | if (profile != null && m_loginService.AuthenticateUser(profile, passwordValues[0])) | 250 | if (account != null && |
251 | (m_authenticationService.Authenticate(account.PrincipalID, passwordValues[0], 30) != string.Empty)) | ||
245 | authRequest.IsAuthenticated = true; | 252 | authRequest.IsAuthenticated = true; |
246 | else | 253 | else |
247 | authRequest.IsAuthenticated = false; | 254 | authRequest.IsAuthenticated = false; |
@@ -250,7 +257,7 @@ For more information, see <a href='http://openid.net/'>http://openid.net/</a>. | |||
250 | { | 257 | { |
251 | // Authentication was requested, send the client a login form | 258 | // Authentication was requested, send the client a login form |
252 | using (StreamWriter writer = new StreamWriter(response)) | 259 | using (StreamWriter writer = new StreamWriter(response)) |
253 | writer.Write(String.Format(LOGIN_PAGE, profile.FirstName, profile.SurName)); | 260 | writer.Write(String.Format(LOGIN_PAGE, account.FirstName, account.LastName)); |
254 | return; | 261 | return; |
255 | } | 262 | } |
256 | } | 263 | } |
@@ -283,14 +290,14 @@ For more information, see <a href='http://openid.net/'>http://openid.net/</a>. | |||
283 | else | 290 | else |
284 | { | 291 | { |
285 | // Try and lookup this avatar | 292 | // Try and lookup this avatar |
286 | UserProfileData profile; | 293 | UserAccount account; |
287 | if (TryGetProfile(httpRequest.Url, out profile)) | 294 | if (TryGetAccount(httpRequest.Url, out account)) |
288 | { | 295 | { |
289 | using (StreamWriter writer = new StreamWriter(response)) | 296 | using (StreamWriter writer = new StreamWriter(response)) |
290 | { | 297 | { |
291 | // TODO: Print out a full profile page for this avatar | 298 | // TODO: Print out a full profile page for this avatar |
292 | writer.Write(String.Format(OPENID_PAGE, httpRequest.Url.Scheme, | 299 | writer.Write(String.Format(OPENID_PAGE, httpRequest.Url.Scheme, |
293 | httpRequest.Url.Authority, profile.FirstName, profile.SurName)); | 300 | httpRequest.Url.Authority, account.FirstName, account.LastName)); |
294 | } | 301 | } |
295 | } | 302 | } |
296 | else | 303 | else |
@@ -316,7 +323,7 @@ For more information, see <a href='http://openid.net/'>http://openid.net/</a>. | |||
316 | /// <param name="requestUrl">URL to parse for an avatar name</param> | 323 | /// <param name="requestUrl">URL to parse for an avatar name</param> |
317 | /// <param name="profile">Profile data for the avatar</param> | 324 | /// <param name="profile">Profile data for the avatar</param> |
318 | /// <returns>True if the parse and lookup were successful, otherwise false</returns> | 325 | /// <returns>True if the parse and lookup were successful, otherwise false</returns> |
319 | bool TryGetProfile(Uri requestUrl, out UserProfileData profile) | 326 | bool TryGetAccount(Uri requestUrl, out UserAccount account) |
320 | { | 327 | { |
321 | if (requestUrl.Segments.Length == 3 && requestUrl.Segments[1] == "users/") | 328 | if (requestUrl.Segments.Length == 3 && requestUrl.Segments[1] == "users/") |
322 | { | 329 | { |
@@ -326,12 +333,12 @@ For more information, see <a href='http://openid.net/'>http://openid.net/</a>. | |||
326 | 333 | ||
327 | if (name.Length == 2) | 334 | if (name.Length == 2) |
328 | { | 335 | { |
329 | profile = m_loginService.GetTheUser(name[0], name[1]); | 336 | account = m_userAccountService.GetUserAccount(UUID.Zero, name[0], name[1]); |
330 | return (profile != null); | 337 | return (account != null); |
331 | } | 338 | } |
332 | } | 339 | } |
333 | 340 | ||
334 | profile = null; | 341 | account = null; |
335 | return false; | 342 | return false; |
336 | } | 343 | } |
337 | } | 344 | } |