aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/AuthenticationService
diff options
context:
space:
mode:
authorSignpostMarv Martin2011-03-15 10:29:42 +0000
committerJustin Clark-Casey (justincc)2011-03-26 02:28:11 +0000
commitaf3956348fc58613948889e5f85030a454684970 (patch)
treeb313d66bfeeb0deca14482a5833b2cd5a7e4758d /OpenSim/Services/AuthenticationService
parentWebkeyAuthenticationService is now no longer a stub! (diff)
downloadopensim-SC_OLD-af3956348fc58613948889e5f85030a454684970.zip
opensim-SC_OLD-af3956348fc58613948889e5f85030a454684970.tar.gz
opensim-SC_OLD-af3956348fc58613948889e5f85030a454684970.tar.bz2
opensim-SC_OLD-af3956348fc58613948889e5f85030a454684970.tar.xz
Adding a combined auth service, allowing users to login with either web login or password
Signed-off-by: SignpostMarv Martin <me@signpostmarv.name>
Diffstat (limited to 'OpenSim/Services/AuthenticationService')
-rw-r--r--OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs65
1 files changed, 65 insertions, 0 deletions
diff --git a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs
new file mode 100644
index 0000000..0f2fd93
--- /dev/null
+++ b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs
@@ -0,0 +1,65 @@
1using System;
2using System.Collections.Generic;
3using OpenMetaverse;
4using OpenSim.Services.Interfaces;
5using log4net;
6using Nini.Config;
7using System.Reflection;
8using OpenSim.Data;
9using OpenSim.Framework;
10using OpenSim.Framework.Console;
11
12namespace OpenSim.Services.AuthenticationService
13{
14 public class WebkeyOrPasswordAuthenticationService : AuthenticationServiceBase, IAuthenticationService
15 {
16 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
17 public WebkeyOrPasswordAuthenticationService(IConfigSource config)
18 : base(config)
19 {
20 }
21
22 public string Authenticate(UUID principalID, string password, int lifetime)
23 {
24 AuthenticationData data = m_Database.Get(principalID);
25 if (data != null && data.Data != null)
26 {
27 if (data.Data.ContainsKey("webLoginKey"))
28 {
29 m_log.InfoFormat("[Authenticate]: Trying a web key authentication");
30 if (new UUID(password) == UUID.Zero)
31 {
32 m_log.InfoFormat("[Authenticate]: NULL_KEY is not a valid web_login_key");
33 }
34 else
35 {
36 string key = data.Data["webLoginKey"].ToString();
37 m_log.DebugFormat("[WEB LOGIN AUTH]: got {0} for key in db vs {1}", key, password);
38 if (key == password)
39 {
40 data.Data["webLoginKey"] = UUID.Zero.ToString();
41 m_Database.Store(data);
42 return GetToken(principalID, lifetime);
43 }
44 }
45 }
46 if (data.Data.ContainsKey("passwordHash") && data.Data.ContainsKey("passwordSalt"))
47 {
48 m_log.InfoFormat("[Authenticate]: Trying a password authentication");
49 string hashed = Util.Md5Hash(password + ":" + data.Data["passwordSalt"].ToString());
50 m_log.DebugFormat("[PASS AUTH]: got {0}; hashed = {1}; stored = {2}", password, hashed, data.Data["passwordHash"].ToString());
51 if (data.Data["passwordHash"].ToString() == hashed)
52 {
53 return GetToken(principalID, lifetime);
54 }
55 }
56 m_log.DebugFormat("[AUTH SERVICE]: Both password and webLoginKey-based login failed for PrincipalID {0}", principalID);
57 }
58 else
59 {
60 m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} or its data not found", principalID);
61 }
62 return string.Empty;
63 }
64 }
65}