aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Data/IAuthenticationData.cs4
-rw-r--r--OpenSim/Data/MySQL/MySQLAuthenticationData.cs55
-rw-r--r--OpenSim/Data/MySQL/Resources/001_AuthStore.sql21
-rw-r--r--OpenSim/Framework/LandData.cs33
-rw-r--r--OpenSim/Server/Base/ServerUtils.cs29
-rw-r--r--OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs2
-rw-r--r--OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs233
-rw-r--r--OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs24
-rw-r--r--OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs28
-rw-r--r--OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs12
-rw-r--r--OpenSim/Services/Interfaces/IAuthenticationService.cs4
-rw-r--r--bin/OpenSim.Server.ini.example15
-rw-r--r--prebuild.xml2
13 files changed, 434 insertions, 28 deletions
diff --git a/OpenSim/Data/IAuthenticationData.cs b/OpenSim/Data/IAuthenticationData.cs
index f848716..7753e04 100644
--- a/OpenSim/Data/IAuthenticationData.cs
+++ b/OpenSim/Data/IAuthenticationData.cs
@@ -48,5 +48,9 @@ namespace OpenSim.Data
48 bool Store(AuthenticationData data); 48 bool Store(AuthenticationData data);
49 49
50 bool SetDataItem(UUID principalID, string item, string value); 50 bool SetDataItem(UUID principalID, string item, string value);
51
52 bool SetToken(UUID principalID, string token, int lifetime);
53
54 bool CheckToken(UUID principalID, string token, int lifetime);
51 } 55 }
52} 56}
diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
index 19575ec..afd59bd 100644
--- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
+++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
@@ -39,11 +39,15 @@ namespace OpenSim.Data.MySQL
39 { 39 {
40 private string m_Realm; 40 private string m_Realm;
41 private List<string> m_ColumnNames = null; 41 private List<string> m_ColumnNames = null;
42 private int m_LastExpire = 0;
42 43
43 public MySqlAuthenticationData(string connectionString, string realm) 44 public MySqlAuthenticationData(string connectionString, string realm)
44 : base(connectionString) 45 : base(connectionString)
45 { 46 {
46 m_Realm = realm; 47 m_Realm = realm;
48
49 Migration m = new Migration(m_Connection, GetType().Assembly, "AuthStore");
50 m.Update();
47 } 51 }
48 52
49 public AuthenticationData Get(UUID principalID) 53 public AuthenticationData Get(UUID principalID)
@@ -153,5 +157,56 @@ namespace OpenSim.Data.MySQL
153 157
154 return false; 158 return false;
155 } 159 }
160
161 public bool SetToken(UUID principalID, string token, int lifetime)
162 {
163 if (System.Environment.TickCount - m_LastExpire > 30000)
164 DoExpire();
165
166 MySqlCommand cmd = new MySqlCommand("insert into tokens (UUID, token, validity) values (?principalID, ?token, date_add(now(), interval ?lifetime minute))");
167 cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
168 cmd.Parameters.AddWithValue("?token", token);
169 cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString());
170
171 if (ExecuteNonQuery(cmd) > 0)
172 {
173 cmd.Dispose();
174 return true;
175 }
176
177 cmd.Dispose();
178 return false;
179 }
180
181 public bool CheckToken(UUID principalID, string token, int lifetime)
182 {
183 if (System.Environment.TickCount - m_LastExpire > 30000)
184 DoExpire();
185
186 MySqlCommand cmd = new MySqlCommand("update tokens set validity = date_add(now(), interval ?lifetime minute) where UUID = ?principalID and token = ?token and validity > now()");
187 cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
188 cmd.Parameters.AddWithValue("?token", token);
189 cmd.Parameters.AddWithValue("?lifetime", lifetime.ToString());
190
191 if (ExecuteNonQuery(cmd) > 0)
192 {
193 cmd.Dispose();
194 return true;
195 }
196
197 cmd.Dispose();
198
199 return false;
200 }
201
202 private void DoExpire()
203 {
204 MySqlCommand cmd = new MySqlCommand("delete from tokens where validity < now()");
205 ExecuteNonQuery(cmd);
206
207 cmd.Dispose();
208
209 m_LastExpire = System.Environment.TickCount;
210 }
156 } 211 }
157} 212}
diff --git a/OpenSim/Data/MySQL/Resources/001_AuthStore.sql b/OpenSim/Data/MySQL/Resources/001_AuthStore.sql
new file mode 100644
index 0000000..c7e16fb
--- /dev/null
+++ b/OpenSim/Data/MySQL/Resources/001_AuthStore.sql
@@ -0,0 +1,21 @@
1begin;
2
3CREATE TABLE `auth` (
4 `UUID` char(36) NOT NULL,
5 `passwordHash` char(32) NOT NULL default '',
6 `passwordSalt` char(32) NOT NULL default '',
7 `webLoginKey` varchar(255) NOT NULL default '',
8 PRIMARY KEY (`UUID`)
9) ENGINE=InnoDB;
10
11CREATE TABLE `tokens` (
12 `UUID` char(36) NOT NULL,
13 `token` varchar(255) NOT NULL,
14 `validity` datetime NOT NULL,
15 UNIQUE KEY `uuid_token` (`UUID`,`token`),
16 KEY `UUID` (`UUID`),
17 KEY `token` (`token`),
18 KEY `validity` (`validity`)
19) ENGINE=InnoDB;
20
21commit;
diff --git a/OpenSim/Framework/LandData.cs b/OpenSim/Framework/LandData.cs
index e639da0..071a667 100644
--- a/OpenSim/Framework/LandData.cs
+++ b/OpenSim/Framework/LandData.cs
@@ -27,6 +27,9 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Xml;
31using System.Xml.Serialization;
32
30using OpenMetaverse; 33using OpenMetaverse;
31 34
32namespace OpenSim.Framework 35namespace OpenSim.Framework
@@ -36,6 +39,11 @@ namespace OpenSim.Framework
36 /// </summary> 39 /// </summary>
37 public class LandData 40 public class LandData
38 { 41 {
42 // use only one serializer to give the runtime a chance to
43 // optimize it (it won't do that if you use a new instance
44 // every time)
45 private static XmlSerializer serializer = new XmlSerializer(typeof (LandData));
46
39 private Vector3 _AABBMax = new Vector3(); 47 private Vector3 _AABBMax = new Vector3();
40 private Vector3 _AABBMin = new Vector3(); 48 private Vector3 _AABBMin = new Vector3();
41 private int _area = 0; 49 private int _area = 0;
@@ -86,6 +94,7 @@ namespace OpenSim.Framework
86 /// <summary> 94 /// <summary>
87 /// Upper corner of the AABB for the parcel 95 /// Upper corner of the AABB for the parcel
88 /// </summary> 96 /// </summary>
97 [XmlIgnore]
89 public Vector3 AABBMax { 98 public Vector3 AABBMax {
90 get { 99 get {
91 return _AABBMax; 100 return _AABBMax;
@@ -97,6 +106,7 @@ namespace OpenSim.Framework
97 /// <summary> 106 /// <summary>
98 /// Lower corner of the AABB for the parcel 107 /// Lower corner of the AABB for the parcel
99 /// </summary> 108 /// </summary>
109 [XmlIgnore]
100 public Vector3 AABBMin { 110 public Vector3 AABBMin {
101 get { 111 get {
102 return _AABBMin; 112 return _AABBMin;
@@ -205,6 +215,7 @@ namespace OpenSim.Framework
205 /// <summary> 215 /// <summary>
206 /// Number of SceneObjectPart that are owned by a Group 216 /// Number of SceneObjectPart that are owned by a Group
207 /// </summary> 217 /// </summary>
218 [XmlIgnore]
208 public int GroupPrims { 219 public int GroupPrims {
209 get { 220 get {
210 return _groupPrims; 221 return _groupPrims;
@@ -363,6 +374,7 @@ namespace OpenSim.Framework
363 /// Number of SceneObjectPart that are owned by users who do not own the parcel 374 /// Number of SceneObjectPart that are owned by users who do not own the parcel
364 /// and don't have the 'group. These are elegable for AutoReturn collection 375 /// and don't have the 'group. These are elegable for AutoReturn collection
365 /// </summary> 376 /// </summary>
377 [XmlIgnore]
366 public int OtherPrims { 378 public int OtherPrims {
367 get { 379 get {
368 return _otherPrims; 380 return _otherPrims;
@@ -388,6 +400,7 @@ namespace OpenSim.Framework
388 /// <summary> 400 /// <summary>
389 /// Number of SceneObjectPart that are owned by the owner of the parcel 401 /// Number of SceneObjectPart that are owned by the owner of the parcel
390 /// </summary> 402 /// </summary>
403 [XmlIgnore]
391 public int OwnerPrims { 404 public int OwnerPrims {
392 get { 405 get {
393 return _ownerPrims; 406 return _ownerPrims;
@@ -448,6 +461,7 @@ namespace OpenSim.Framework
448 /// <summary> 461 /// <summary>
449 /// Number of SceneObjectPart that are currently selected by avatar 462 /// Number of SceneObjectPart that are currently selected by avatar
450 /// </summary> 463 /// </summary>
464 [XmlIgnore]
451 public int SelectedPrims { 465 public int SelectedPrims {
452 get { 466 get {
453 return _selectedPrims; 467 return _selectedPrims;
@@ -460,6 +474,7 @@ namespace OpenSim.Framework
460 /// <summary> 474 /// <summary>
461 /// Number of meters^2 in the Simulator 475 /// Number of meters^2 in the Simulator
462 /// </summary> 476 /// </summary>
477 [XmlIgnore]
463 public int SimwideArea { 478 public int SimwideArea {
464 get { 479 get {
465 return _simwideArea; 480 return _simwideArea;
@@ -472,6 +487,7 @@ namespace OpenSim.Framework
472 /// <summary> 487 /// <summary>
473 /// Number of SceneObjectPart in the Simulator 488 /// Number of SceneObjectPart in the Simulator
474 /// </summary> 489 /// </summary>
490 [XmlIgnore]
475 public int SimwidePrims { 491 public int SimwidePrims {
476 get { 492 get {
477 return _simwidePrims; 493 return _simwidePrims;
@@ -607,5 +623,22 @@ namespace OpenSim.Framework
607 623
608 return landData; 624 return landData;
609 } 625 }
626
627 public void ToXml(XmlWriter xmlWriter)
628 {
629 serializer.Serialize(xmlWriter, this);
630 }
631
632 /// <summary>
633 /// Restore a LandData object from the serialized xml representation.
634 /// </summary>
635 /// <param name="xmlReader"></param>
636 /// <returns></returns>
637 public static LandData FromXml(XmlReader xmlReader)
638 {
639 LandData land = (LandData)serializer.Deserialize(xmlReader);
640
641 return land;
642 }
610 } 643 }
611} 644}
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs
index 8d76ffe..0a36bbe 100644
--- a/OpenSim/Server/Base/ServerUtils.cs
+++ b/OpenSim/Server/Base/ServerUtils.cs
@@ -31,6 +31,7 @@ using System.Reflection;
31using System.Xml; 31using System.Xml;
32using System.Xml.Serialization; 32using System.Xml.Serialization;
33using System.Text; 33using System.Text;
34using System.Collections.Generic;
34using log4net; 35using log4net;
35using OpenSim.Framework; 36using OpenSim.Framework;
36 37
@@ -156,5 +157,31 @@ namespace OpenSim.Server.Base
156 return null; 157 return null;
157 } 158 }
158 } 159 }
160
161 public static Dictionary<string, string> ParseQueryString(string query)
162 {
163 Dictionary<string, string> result = new Dictionary<string, string>();
164 string[] terms = query.Split(new char[] {'&'});
165
166 if (terms.Length == 0)
167 return result;
168
169 foreach (string t in terms)
170 {
171 string[] elems = t.Split(new char[] {'='});
172 if (elems.Length == 0)
173 continue;
174
175 string name = System.Web.HttpUtility.UrlDecode(elems[0]);
176 string value = String.Empty;
177
178 if (elems.Length > 1)
179 value = System.Web.HttpUtility.UrlDecode(elems[1]);
180
181 result[name] = value;
182 }
183
184 return result;
185 }
159 } 186 }
160} \ No newline at end of file 187}
diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs
index 03a7980..589dc3b 100644
--- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs
+++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs
@@ -54,7 +54,7 @@ namespace OpenSim.Server.Handlers.Authentication
54 Object[] args = new Object[] { config }; 54 Object[] args = new Object[] { config };
55 m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authenticationService, args); 55 m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authenticationService, args);
56 56
57 //server.AddStreamHandler(new AuthenticationServerGetHandler(m_AuthenticationService)); 57 server.AddStreamHandler(new AuthenticationServerPostHandler(m_AuthenticationService));
58 } 58 }
59 } 59 }
60} 60}
diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
new file mode 100644
index 0000000..6cf7d56
--- /dev/null
+++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
@@ -0,0 +1,233 @@
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 OpenSimulator 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
28using Nini.Config;
29using log4net;
30using System;
31using System.Reflection;
32using System.IO;
33using System.Net;
34using System.Text;
35using System.Text.RegularExpressions;
36using System.Xml;
37using System.Xml.Serialization;
38using System.Collections.Generic;
39using OpenSim.Server.Base;
40using OpenSim.Services.Interfaces;
41using OpenSim.Framework;
42using OpenSim.Framework.Servers.HttpServer;
43using OpenMetaverse;
44
45namespace OpenSim.Server.Handlers.Authentication
46{
47 public class AuthenticationServerPostHandler : BaseStreamHandler
48 {
49 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50
51 private IAuthenticationService m_AuthenticationService;
52
53 public AuthenticationServerPostHandler(IAuthenticationService service) :
54 base("POST", "/auth")
55 {
56 m_AuthenticationService = service;
57 }
58
59 public override byte[] Handle(string path, Stream request,
60 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
61 {
62 string[] p = SplitParams(path);
63
64 if (p.Length > 0)
65 {
66 switch (p[0])
67 {
68 case "plain":
69 StreamReader sr = new StreamReader(request);
70 string body = sr.ReadToEnd();
71 sr.Close();
72
73 return DoPlainMethods(body);
74 case "crypt":
75 byte[] buffer = new byte[request.Length];
76 long length = request.Length;
77 if (length > 16384)
78 length = 16384;
79 request.Read(buffer, 0, (int)length);
80
81 return DoEncryptedMethods(buffer);
82 }
83 }
84 return new byte[0];
85 }
86
87 private byte[] DoPlainMethods(string body)
88 {
89 Dictionary<string, string> request =
90 ServerUtils.ParseQueryString(body);
91
92 int lifetime = 30;
93
94 if (request.ContainsKey("LIFETIME"))
95 {
96 lifetime = Convert.ToInt32(request["LIFETIME"]);
97 if (lifetime > 30)
98 lifetime = 30;
99 }
100
101 if (!request.ContainsKey("METHOD"))
102 return FailureResult();
103 if (!request.ContainsKey("PRINCIPAL"))
104 return FailureResult();
105
106 string method = request["METHOD"];
107
108 UUID principalID;
109 string token;
110
111 if (!UUID.TryParse(request["PRINCIPAL"], out principalID))
112 return FailureResult();
113
114 switch (method)
115 {
116 case "authenticate":
117 if (!request.ContainsKey("PASSWORD"))
118 return FailureResult();
119
120 token = m_AuthenticationService.Authenticate(principalID, request["PASSWORD"], lifetime);
121
122 if (token != String.Empty)
123 return SuccessResult(token);
124 return FailureResult();
125 case "verify":
126 if (!request.ContainsKey("TOKEN"))
127 return FailureResult();
128
129 if (m_AuthenticationService.Verify(principalID, request["TOKEN"], lifetime))
130 return SuccessResult();
131
132 return FailureResult();
133 case "release":
134 if (!request.ContainsKey("TOKEN"))
135 return FailureResult();
136
137 if (m_AuthenticationService.Release(principalID, request["TOKEN"]))
138 return SuccessResult();
139
140 return FailureResult();
141 }
142
143 return FailureResult();
144 }
145
146 private byte[] DoEncryptedMethods(byte[] ciphertext)
147 {
148 return new byte[0];
149 }
150
151 private byte[] SuccessResult()
152 {
153 XmlDocument doc = new XmlDocument();
154
155 XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
156 "", "");
157
158 doc.AppendChild(xmlnode);
159
160 XmlElement rootElement = doc.CreateElement("", "Authentication",
161 "");
162
163 doc.AppendChild(rootElement);
164
165 XmlElement result = doc.CreateElement("", "Result", "");
166 result.AppendChild(doc.CreateTextNode("Success"));
167
168 rootElement.AppendChild(result);
169
170 return DocToBytes(doc);
171 }
172
173 private byte[] FailureResult()
174 {
175 XmlDocument doc = new XmlDocument();
176
177 XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
178 "", "");
179
180 doc.AppendChild(xmlnode);
181
182 XmlElement rootElement = doc.CreateElement("", "Authentication",
183 "");
184
185 doc.AppendChild(rootElement);
186
187 XmlElement result = doc.CreateElement("", "Result", "");
188 result.AppendChild(doc.CreateTextNode("Failure"));
189
190 rootElement.AppendChild(result);
191
192 return DocToBytes(doc);
193 }
194
195 private byte[] SuccessResult(string token)
196 {
197 XmlDocument doc = new XmlDocument();
198
199 XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
200 "", "");
201
202 doc.AppendChild(xmlnode);
203
204 XmlElement rootElement = doc.CreateElement("", "Authentication",
205 "");
206
207 doc.AppendChild(rootElement);
208
209 XmlElement result = doc.CreateElement("", "Result", "");
210 result.AppendChild(doc.CreateTextNode("Success"));
211
212 rootElement.AppendChild(result);
213
214 XmlElement t = doc.CreateElement("", "Token", "");
215 t.AppendChild(doc.CreateTextNode(token));
216
217 rootElement.AppendChild(t);
218
219 return DocToBytes(doc);
220 }
221
222 private byte[] DocToBytes(XmlDocument doc)
223 {
224 MemoryStream ms = new MemoryStream();
225 XmlTextWriter xw = new XmlTextWriter(ms, null);
226 xw.Formatting = Formatting.Indented;
227 doc.WriteTo(xw);
228 xw.Flush();
229
230 return ms.GetBuffer();
231 }
232 }
233}
diff --git a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
index 200268b..2ed177c 100644
--- a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
+++ b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs
@@ -53,7 +53,7 @@ namespace OpenSim.Services.AuthenticationService
53 { 53 {
54 string dllName = String.Empty; 54 string dllName = String.Empty;
55 string connString = String.Empty; 55 string connString = String.Empty;
56 string realm = String.Empty; 56 string realm = "auth";
57 57
58 // 58 //
59 // Try reading the [AuthenticationService] section first, if it exists 59 // Try reading the [AuthenticationService] section first, if it exists
@@ -95,14 +95,34 @@ namespace OpenSim.Services.AuthenticationService
95 return new byte[0]; 95 return new byte[0];
96 } 96 }
97 97
98 public virtual bool Release(UUID principalID, string token) 98 public bool Verify(UUID principalID, string token, int lifetime)
99 {
100 return m_Database.CheckToken(principalID, token, lifetime);
101 }
102
103 public bool VerifyEncrypted(byte[] cyphertext, byte[] key)
99 { 104 {
100 return false; 105 return false;
101 } 106 }
102 107
108 public virtual bool Release(UUID principalID, string token)
109 {
110 return m_Database.CheckToken(principalID, token, 0);
111 }
112
103 public virtual bool ReleaseEncrypted(byte[] cyphertext, byte[] key) 113 public virtual bool ReleaseEncrypted(byte[] cyphertext, byte[] key)
104 { 114 {
105 return false; 115 return false;
106 } 116 }
117
118 protected string GetToken(UUID principalID, int lifetime)
119 {
120 UUID token = UUID.Random();
121
122 if (m_Database.SetToken(principalID, token.ToString(), lifetime))
123 return token.ToString();
124
125 return String.Empty;
126 }
107 } 127 }
108} 128}
diff --git a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
index 83ce0d0..7fdbbf6 100644
--- a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
+++ b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
@@ -56,8 +56,24 @@ namespace OpenSim.Services.AuthenticationService
56 { 56 {
57 } 57 }
58 58
59 public string Authenticate(UUID principalID, string password) 59 public string Authenticate(UUID principalID, string password, int lifetime)
60 { 60 {
61 AuthenticationData data = m_Database.Get(principalID);
62
63 if (!data.Data.ContainsKey("passwordHash") ||
64 !data.Data.ContainsKey("passwordSalt"))
65 {
66 return String.Empty;
67 }
68
69 string hashed = Util.Md5Hash(Util.Md5Hash(password) + ":" +
70 data.Data["passwordSalt"].ToString());
71
72 if (data.Data["passwordHash"].ToString() == hashed)
73 {
74 return GetToken(principalID, lifetime);
75 }
76
61 return String.Empty; 77 return String.Empty;
62 } 78 }
63 79
@@ -65,15 +81,5 @@ namespace OpenSim.Services.AuthenticationService
65 { 81 {
66 return new byte[0]; 82 return new byte[0];
67 } 83 }
68
69 public bool Verify(UUID principalID, string token)
70 {
71 return false;
72 }
73
74 public bool VerifyEncrypted(byte[] cyphertext, byte[] key)
75 {
76 return false;
77 }
78 } 84 }
79} 85}
diff --git a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs
index af55df0..0118c91 100644
--- a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs
+++ b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs
@@ -52,7 +52,7 @@ namespace OpenSim.Services.AuthenticationService
52 { 52 {
53 } 53 }
54 54
55 public string Authenticate(UUID principalID, string password) 55 public string Authenticate(UUID principalID, string password, int lifetime)
56 { 56 {
57 return String.Empty; 57 return String.Empty;
58 } 58 }
@@ -61,15 +61,5 @@ namespace OpenSim.Services.AuthenticationService
61 { 61 {
62 return new byte[0]; 62 return new byte[0];
63 } 63 }
64
65 public bool Verify(UUID principalID, string token)
66 {
67 return false;
68 }
69
70 public bool VerifyEncrypted(byte[] cyphertext, byte[] key)
71 {
72 return false;
73 }
74 } 64 }
75} 65}
diff --git a/OpenSim/Services/Interfaces/IAuthenticationService.cs b/OpenSim/Services/Interfaces/IAuthenticationService.cs
index f042c93..b448a14 100644
--- a/OpenSim/Services/Interfaces/IAuthenticationService.cs
+++ b/OpenSim/Services/Interfaces/IAuthenticationService.cs
@@ -70,7 +70,7 @@ namespace OpenSim.Services.Interfaces
70 // the public key of the peer, which the connector must have 70 // the public key of the peer, which the connector must have
71 // obtained using a remote GetPublicKey call. 71 // obtained using a remote GetPublicKey call.
72 // 72 //
73 string Authenticate(UUID principalID, string password); 73 string Authenticate(UUID principalID, string password, int lifetime);
74 byte[] AuthenticateEncrypted(byte[] cyphertext, byte[] key); 74 byte[] AuthenticateEncrypted(byte[] cyphertext, byte[] key);
75 75
76 ////////////////////////////////////////////////////// 76 //////////////////////////////////////////////////////
@@ -85,7 +85,7 @@ namespace OpenSim.Services.Interfaces
85 // must be used to refresh. Unencrypted verification is still 85 // must be used to refresh. Unencrypted verification is still
86 // performed, but doesn't refresh token lifetime. 86 // performed, but doesn't refresh token lifetime.
87 // 87 //
88 bool Verify(UUID principalID, string token); 88 bool Verify(UUID principalID, string token, int lifetime);
89 bool VerifyEncrypted(byte[] cyphertext, byte[] key); 89 bool VerifyEncrypted(byte[] cyphertext, byte[] key);
90 90
91 ////////////////////////////////////////////////////// 91 //////////////////////////////////////////////////////
diff --git a/bin/OpenSim.Server.ini.example b/bin/OpenSim.Server.ini.example
index aab0566..545d6ce 100644
--- a/bin/OpenSim.Server.ini.example
+++ b/bin/OpenSim.Server.ini.example
@@ -5,6 +5,9 @@
5; * These are the IN connectors the server uses, the in connectors 5; * These are the IN connectors the server uses, the in connectors
6; * read this config file and load the needed OUT and database connectors 6; * read this config file and load the needed OUT and database connectors
7; * 7; *
8; * Add "OpenSim.Server.Handlers.dll:AuthenticationServiceConnector" to
9; * enable the experimental authentication service
10; *
8[Startup] 11[Startup]
9ServiceConnectors = "OpenSim.Server.Handlers.dll:AssetServiceConnector,OpenSim.Server.Handlers.dll:InventoryServiceInConnector,OpenSim.Server.Handlers.dll:FreeswitchServerConnector" 12ServiceConnectors = "OpenSim.Server.Handlers.dll:AssetServiceConnector,OpenSim.Server.Handlers.dll:InventoryServiceInConnector,OpenSim.Server.Handlers.dll:FreeswitchServerConnector"
10 13
@@ -45,3 +48,15 @@ ConnectionString = "Data Source=localhost;Database=grid;User ID=grid;Password=gr
45; * This is the configuration for the freeswitch server in grid mode 48; * This is the configuration for the freeswitch server in grid mode
46[FreeswitchService] 49[FreeswitchService]
47LocalServiceModule = "OpenSim.Services.FreeswitchService.dll:FreeswitchService" 50LocalServiceModule = "OpenSim.Services.FreeswitchService.dll:FreeswitchService"
51
52; * This is the new style authentication service. Currently, only MySQL
53; * is implemented. "Realm" is the table that is used for user lookup.
54; * By setting it to "users", you can use the old style users table
55; * as an authentication source.
56; *
57[AuthenticationService]
58AuthenticationServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"
59StorageProvider = "OpenSim.Data.MySQL.dll"
60ConnectionString = "Data Source=localhost;Database=grid;User ID=grid;Password=grid;"
61; Realm = "auth"
62
diff --git a/prebuild.xml b/prebuild.xml
index cdffd8a..b84fddd 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -1399,6 +1399,7 @@
1399 <ReferencePath>../../../bin/</ReferencePath> 1399 <ReferencePath>../../../bin/</ReferencePath>
1400 <Reference name="System"/> 1400 <Reference name="System"/>
1401 <Reference name="System.Xml"/> 1401 <Reference name="System.Xml"/>
1402 <Reference name="System.Web"/>
1402 <Reference name="OpenMetaverseTypes.dll"/> 1403 <Reference name="OpenMetaverseTypes.dll"/>
1403 <Reference name="OpenMetaverse.dll"/> 1404 <Reference name="OpenMetaverse.dll"/>
1404 <Reference name="OpenSim.Framework"/> 1405 <Reference name="OpenSim.Framework"/>
@@ -1427,6 +1428,7 @@
1427 <ReferencePath>../../../bin/</ReferencePath> 1428 <ReferencePath>../../../bin/</ReferencePath>
1428 <Reference name="System"/> 1429 <Reference name="System"/>
1429 <Reference name="System.Xml"/> 1430 <Reference name="System.Xml"/>
1431 <Reference name="System.Web"/>
1430 <Reference name="OpenMetaverseTypes.dll"/> 1432 <Reference name="OpenMetaverseTypes.dll"/>
1431 <Reference name="OpenMetaverse.dll"/> 1433 <Reference name="OpenMetaverse.dll"/>
1432 <Reference name="OpenMetaverse.StructuredData.dll"/> 1434 <Reference name="OpenMetaverse.StructuredData.dll"/>