diff options
author | Justin Clark-Casey (justincc) | 2011-10-24 21:34:44 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-10-24 21:40:36 +0100 |
commit | 4c9400e6460a73baa2d687afe73a62c6efca9f37 (patch) | |
tree | 9302270fbf46288ef5aeccbac0c0925e6f1a118b | |
parent | Comment out the uuid gatherer lines that I accidentally left in. (diff) | |
download | opensim-SC_OLD-4c9400e6460a73baa2d687afe73a62c6efca9f37.zip opensim-SC_OLD-4c9400e6460a73baa2d687afe73a62c6efca9f37.tar.gz opensim-SC_OLD-4c9400e6460a73baa2d687afe73a62c6efca9f37.tar.bz2 opensim-SC_OLD-4c9400e6460a73baa2d687afe73a62c6efca9f37.tar.xz |
Add optional getauthinfo and setauthinfo authentication service calls.
These are disabled by default, as before. Please only turn these on in secure grids, since they allow the same facilities as the existing SetPassword call (also disabled by default)
These facilities can be helpful when integrating external systems, in addition to the existing option of adapting an IAuthenticationService or using WebLoginKey
Diffstat (limited to '')
9 files changed, 193 insertions, 5 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs index acc362b..9484a5a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs | |||
@@ -158,7 +158,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication | |||
158 | return m_AuthenticationService.SetPassword(principalID, passwd); | 158 | return m_AuthenticationService.SetPassword(principalID, passwd); |
159 | } | 159 | } |
160 | 160 | ||
161 | #endregion | 161 | public AuthInfo GetAuthInfo(UUID principalID) |
162 | { | ||
163 | return m_AuthenticationService.GetAuthInfo(principalID); | ||
164 | } | ||
162 | 165 | ||
166 | public bool SetAuthInfo(AuthInfo info) | ||
167 | { | ||
168 | return m_AuthenticationService.SetAuthInfo(info); | ||
169 | } | ||
170 | |||
171 | #endregion | ||
163 | } | 172 | } |
164 | } | 173 | } |
diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs index ae71945..4d1b0ff 100644 --- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs | |||
@@ -46,9 +46,12 @@ namespace OpenSim.Server.Handlers.Authentication | |||
46 | { | 46 | { |
47 | public class AuthenticationServerPostHandler : BaseStreamHandler | 47 | public class AuthenticationServerPostHandler : BaseStreamHandler |
48 | { | 48 | { |
49 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
50 | 50 | ||
51 | private IAuthenticationService m_AuthenticationService; | 51 | private IAuthenticationService m_AuthenticationService; |
52 | |||
53 | private bool m_AllowGetAuthInfo = false; | ||
54 | private bool m_AllowSetAuthInfo = false; | ||
52 | private bool m_AllowSetPassword = false; | 55 | private bool m_AllowSetPassword = false; |
53 | 56 | ||
54 | public AuthenticationServerPostHandler(IAuthenticationService service) : | 57 | public AuthenticationServerPostHandler(IAuthenticationService service) : |
@@ -61,6 +64,8 @@ namespace OpenSim.Server.Handlers.Authentication | |||
61 | 64 | ||
62 | if (config != null) | 65 | if (config != null) |
63 | { | 66 | { |
67 | m_AllowGetAuthInfo = config.GetBoolean("AllowGetAuthInfo", m_AllowGetAuthInfo); | ||
68 | m_AllowSetAuthInfo = config.GetBoolean("AllowSetAuthInfo", m_AllowSetAuthInfo); | ||
64 | m_AllowSetPassword = config.GetBoolean("AllowSetPassword", m_AllowSetPassword); | 69 | m_AllowSetPassword = config.GetBoolean("AllowSetPassword", m_AllowSetPassword); |
65 | } | 70 | } |
66 | } | 71 | } |
@@ -161,6 +166,18 @@ namespace OpenSim.Server.Handlers.Authentication | |||
161 | return SuccessResult(); | 166 | return SuccessResult(); |
162 | 167 | ||
163 | return FailureResult(); | 168 | return FailureResult(); |
169 | |||
170 | case "getauthinfo": | ||
171 | if (m_AllowGetAuthInfo) | ||
172 | return GetAuthInfo(principalID); | ||
173 | |||
174 | break; | ||
175 | |||
176 | case "setauthinfo": | ||
177 | if (m_AllowSetAuthInfo) | ||
178 | return SetAuthInfo(principalID, request); | ||
179 | |||
180 | break; | ||
164 | } | 181 | } |
165 | 182 | ||
166 | return FailureResult(); | 183 | return FailureResult(); |
@@ -193,6 +210,54 @@ namespace OpenSim.Server.Handlers.Authentication | |||
193 | return DocToBytes(doc); | 210 | return DocToBytes(doc); |
194 | } | 211 | } |
195 | 212 | ||
213 | byte[] GetAuthInfo(UUID principalID) | ||
214 | { | ||
215 | AuthInfo info = m_AuthenticationService.GetAuthInfo(principalID); | ||
216 | |||
217 | if (info != null) | ||
218 | { | ||
219 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
220 | result["result"] = info.ToKeyValuePairs(); | ||
221 | |||
222 | return ResultToBytes(result); | ||
223 | } | ||
224 | else | ||
225 | { | ||
226 | return FailureResult(); | ||
227 | } | ||
228 | } | ||
229 | |||
230 | byte[] SetAuthInfo(UUID principalID, Dictionary<string, object> request) | ||
231 | { | ||
232 | AuthInfo existingInfo = m_AuthenticationService.GetAuthInfo(principalID); | ||
233 | |||
234 | if (existingInfo == null) | ||
235 | return FailureResult(); | ||
236 | |||
237 | if (request.ContainsKey("AccountType")) | ||
238 | existingInfo.AccountType = request["AccountType"].ToString(); | ||
239 | |||
240 | if (request.ContainsKey("PasswordHash")) | ||
241 | existingInfo.PasswordHash = request["PasswordHash"].ToString(); | ||
242 | |||
243 | if (request.ContainsKey("PasswordSalt")) | ||
244 | existingInfo.PasswordSalt = request["PasswordSalt"].ToString(); | ||
245 | |||
246 | if (request.ContainsKey("WebLoginKey")) | ||
247 | existingInfo.WebLoginKey = request["WebLoginKey"].ToString(); | ||
248 | |||
249 | if (!m_AuthenticationService.SetAuthInfo(existingInfo)) | ||
250 | { | ||
251 | m_log.ErrorFormat( | ||
252 | "[AUTHENTICATION SERVER POST HANDLER]: Authentication info store failed for account {0} {1} {2}", | ||
253 | existingInfo.PrincipalID); | ||
254 | |||
255 | return FailureResult(); | ||
256 | } | ||
257 | |||
258 | return SuccessResult(); | ||
259 | } | ||
260 | |||
196 | private byte[] FailureResult() | 261 | private byte[] FailureResult() |
197 | { | 262 | { |
198 | XmlDocument doc = new XmlDocument(); | 263 | XmlDocument doc = new XmlDocument(); |
@@ -252,5 +317,12 @@ namespace OpenSim.Server.Handlers.Authentication | |||
252 | 317 | ||
253 | return ms.GetBuffer(); | 318 | return ms.GetBuffer(); |
254 | } | 319 | } |
320 | |||
321 | private byte[] ResultToBytes(Dictionary<string, object> result) | ||
322 | { | ||
323 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
324 | UTF8Encoding encoding = new UTF8Encoding(); | ||
325 | return encoding.GetBytes(xmlString); | ||
326 | } | ||
255 | } | 327 | } |
256 | } | 328 | } |
diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs index f987383..5ab4caf 100644 --- a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs +++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs | |||
@@ -356,7 +356,5 @@ namespace OpenSim.Server.Handlers.UserAccounts | |||
356 | UTF8Encoding encoding = new UTF8Encoding(); | 356 | UTF8Encoding encoding = new UTF8Encoding(); |
357 | return encoding.GetBytes(xmlString); | 357 | return encoding.GetBytes(xmlString); |
358 | } | 358 | } |
359 | |||
360 | |||
361 | } | 359 | } |
362 | } | 360 | } |
diff --git a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs index edc1097..229f557 100644 --- a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs +++ b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs | |||
@@ -30,9 +30,10 @@ using OpenMetaverse; | |||
30 | using log4net; | 30 | using log4net; |
31 | using Nini.Config; | 31 | using Nini.Config; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using OpenSim.Services.Base; | ||
34 | using OpenSim.Data; | 33 | using OpenSim.Data; |
35 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Services.Base; | ||
36 | using OpenSim.Services.Interfaces; | ||
36 | 37 | ||
37 | namespace OpenSim.Services.AuthenticationService | 38 | namespace OpenSim.Services.AuthenticationService |
38 | { | 39 | { |
@@ -126,6 +127,50 @@ namespace OpenSim.Services.AuthenticationService | |||
126 | m_log.InfoFormat("[AUTHENTICATION DB]: Set password for principalID {0}", principalID); | 127 | m_log.InfoFormat("[AUTHENTICATION DB]: Set password for principalID {0}", principalID); |
127 | return true; | 128 | return true; |
128 | } | 129 | } |
130 | |||
131 | public virtual AuthInfo GetAuthInfo(UUID principalID) | ||
132 | { | ||
133 | AuthenticationData data = m_Database.Get(principalID); | ||
134 | |||
135 | if (data == null) | ||
136 | { | ||
137 | return null; | ||
138 | } | ||
139 | else | ||
140 | { | ||
141 | AuthInfo info | ||
142 | = new AuthInfo() | ||
143 | { | ||
144 | PrincipalID = data.PrincipalID, | ||
145 | AccountType = data.Data["accountType"] as string, | ||
146 | PasswordHash = data.Data["passwordHash"] as string, | ||
147 | PasswordSalt = data.Data["passwordSalt"] as string, | ||
148 | WebLoginKey = data.Data["webLoginKey"] as string | ||
149 | }; | ||
150 | |||
151 | return info; | ||
152 | } | ||
153 | } | ||
154 | |||
155 | public virtual bool SetAuthInfo(AuthInfo info) | ||
156 | { | ||
157 | AuthenticationData auth = new AuthenticationData(); | ||
158 | auth.PrincipalID = info.PrincipalID; | ||
159 | auth.Data = new System.Collections.Generic.Dictionary<string, object>(); | ||
160 | auth.Data["accountType"] = info.AccountType; | ||
161 | auth.Data["webLoginKey"] = info.WebLoginKey; | ||
162 | auth.Data["passwordHash"] = info.PasswordHash; | ||
163 | auth.Data["passwordSalt"] = info.PasswordSalt; | ||
164 | |||
165 | if (!m_Database.Store(auth)) | ||
166 | { | ||
167 | m_log.ErrorFormat("[AUTHENTICATION DB]: Failed to store authentication info."); | ||
168 | return false; | ||
169 | } | ||
170 | |||
171 | m_log.DebugFormat("[AUTHENTICATION DB]: Set authentication info for principalID {0}", info.PrincipalID); | ||
172 | return true; | ||
173 | } | ||
129 | 174 | ||
130 | protected string GetToken(UUID principalID, int lifetime) | 175 | protected string GetToken(UUID principalID, int lifetime) |
131 | { | 176 | { |
diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs index c04e7a4..2b77154 100644 --- a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs | |||
@@ -151,5 +151,17 @@ namespace OpenSim.Services.Connectors | |||
151 | // nope, we don't do this | 151 | // nope, we don't do this |
152 | return false; | 152 | return false; |
153 | } | 153 | } |
154 | |||
155 | public AuthInfo GetAuthInfo(UUID principalID) | ||
156 | { | ||
157 | // not done from remote simulators | ||
158 | return null; | ||
159 | } | ||
160 | |||
161 | public bool SetAuthInfo(AuthInfo info) | ||
162 | { | ||
163 | // not done from remote simulators | ||
164 | return false; | ||
165 | } | ||
154 | } | 166 | } |
155 | } | 167 | } |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs index 51a09f8..69f6ed2 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs | |||
@@ -236,6 +236,16 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
236 | return false; | 236 | return false; |
237 | } | 237 | } |
238 | 238 | ||
239 | public AuthInfo GetAuthInfo(UUID principalID) | ||
240 | { | ||
241 | throw new NotImplementedException(); | ||
242 | } | ||
243 | |||
244 | public bool SetAuthInfo(AuthInfo info) | ||
245 | { | ||
246 | throw new NotImplementedException(); | ||
247 | } | ||
248 | |||
239 | private bool CheckPassword(UUID userID, string password, string simianGridCredential, out string authorizeResult) | 249 | private bool CheckPassword(UUID userID, string password, string simianGridCredential, out string authorizeResult) |
240 | { | 250 | { |
241 | if (simianGridCredential.Contains(":")) | 251 | if (simianGridCredential.Contains(":")) |
diff --git a/OpenSim/Services/Interfaces/IAuthenticationService.cs b/OpenSim/Services/Interfaces/IAuthenticationService.cs index 9de261b..cee8bc0 100644 --- a/OpenSim/Services/Interfaces/IAuthenticationService.cs +++ b/OpenSim/Services/Interfaces/IAuthenticationService.cs | |||
@@ -26,10 +26,32 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using OpenMetaverse; | 30 | using OpenMetaverse; |
30 | 31 | ||
31 | namespace OpenSim.Services.Interfaces | 32 | namespace OpenSim.Services.Interfaces |
32 | { | 33 | { |
34 | public class AuthInfo | ||
35 | { | ||
36 | public UUID PrincipalID { get; set; } | ||
37 | public string AccountType { get; set; } | ||
38 | public string PasswordHash { get; set; } | ||
39 | public string PasswordSalt { get; set; } | ||
40 | public string WebLoginKey { get; set; } | ||
41 | |||
42 | public Dictionary<string, object> ToKeyValuePairs() | ||
43 | { | ||
44 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
45 | result["PrincipalID"] = PrincipalID; | ||
46 | result["AccountType"] = AccountType; | ||
47 | result["PasswordHash"] = PasswordHash; | ||
48 | result["PasswordSalt"] = PasswordSalt; | ||
49 | result["WebLoginKey"] = WebLoginKey; | ||
50 | |||
51 | return result; | ||
52 | } | ||
53 | } | ||
54 | |||
33 | // Generic Authentication service used for identifying | 55 | // Generic Authentication service used for identifying |
34 | // and authenticating principals. | 56 | // and authenticating principals. |
35 | // Principals may be clients acting on users' behalf, | 57 | // Principals may be clients acting on users' behalf, |
@@ -76,6 +98,10 @@ namespace OpenSim.Services.Interfaces | |||
76 | // | 98 | // |
77 | bool SetPassword(UUID principalID, string passwd); | 99 | bool SetPassword(UUID principalID, string passwd); |
78 | 100 | ||
101 | AuthInfo GetAuthInfo(UUID principalID); | ||
102 | |||
103 | bool SetAuthInfo(AuthInfo info); | ||
104 | |||
79 | ////////////////////////////////////////////////////// | 105 | ////////////////////////////////////////////////////// |
80 | // Grid | 106 | // Grid |
81 | // | 107 | // |
diff --git a/bin/Robust.HG.ini.example b/bin/Robust.HG.ini.example index aed1d33..a23063d 100644 --- a/bin/Robust.HG.ini.example +++ b/bin/Robust.HG.ini.example | |||
@@ -146,6 +146,14 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 | |||
146 | LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" | 146 | LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" |
147 | ; Realm = "useraccounts" | 147 | ; Realm = "useraccounts" |
148 | 148 | ||
149 | ;; Allow the service to process HTTP getauthinfo calls. | ||
150 | ;; Default is false. | ||
151 | ; AllowGetAuthInfo = false | ||
152 | |||
153 | ;; Allow the service to process HTTP setauthinfo calls. | ||
154 | ;; Default is false. | ||
155 | ; AllowSetAuthInfo = false | ||
156 | |||
149 | ;; Allow the service to process HTTP setpassword calls. | 157 | ;; Allow the service to process HTTP setpassword calls. |
150 | ;; Default is false. | 158 | ;; Default is false. |
151 | ; AllowSetPassword = false | 159 | ; AllowSetPassword = false |
diff --git a/bin/Robust.ini.example b/bin/Robust.ini.example index 522cc56..897cfde 100644 --- a/bin/Robust.ini.example +++ b/bin/Robust.ini.example | |||
@@ -129,6 +129,14 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 | |||
129 | ; for the server connector | 129 | ; for the server connector |
130 | LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" | 130 | LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" |
131 | 131 | ||
132 | ;; Allow the service to process HTTP getauthinfo calls. | ||
133 | ;; Default is false. | ||
134 | ; AllowGetAuthInfo = false | ||
135 | |||
136 | ;; Allow the service to process HTTP setauthinfo calls. | ||
137 | ;; Default is false. | ||
138 | ; AllowSetAuthInfo = false | ||
139 | |||
132 | ;; Allow the service to process HTTP setpassword calls. | 140 | ;; Allow the service to process HTTP setpassword calls. |
133 | ;; Default is false. | 141 | ;; Default is false. |
134 | ; AllowSetPassword = false | 142 | ; AllowSetPassword = false |