diff options
author | Justin Clark-Casey (justincc) | 2011-10-19 00:06:40 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-10-19 00:06:40 +0100 |
commit | 9d59b285bbc84aa620200e7da69be0f347dd69f4 (patch) | |
tree | 9bf78d665169c39a10d9e0160d60e3f7262e962d | |
parent | Provide an option to allow remote calls to the CreateUser method on the UserA... (diff) | |
download | opensim-SC-9d59b285bbc84aa620200e7da69be0f347dd69f4.zip opensim-SC-9d59b285bbc84aa620200e7da69be0f347dd69f4.tar.gz opensim-SC-9d59b285bbc84aa620200e7da69be0f347dd69f4.tar.bz2 opensim-SC-9d59b285bbc84aa620200e7da69be0f347dd69f4.tar.xz |
Allow an http call to set account details if AllowSetAccount = true in [UserAccountService].
As before, default is false to not allow these calls.
-rw-r--r-- | OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs | 62 | ||||
-rw-r--r-- | bin/Robust.HG.ini.example | 4 | ||||
-rw-r--r-- | bin/Robust.ini.example | 5 |
3 files changed, 67 insertions, 4 deletions
diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs index deadce2..aba4f7b 100644 --- a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs +++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs | |||
@@ -51,6 +51,7 @@ namespace OpenSim.Server.Handlers.UserAccounts | |||
51 | 51 | ||
52 | private IUserAccountService m_UserAccountService; | 52 | private IUserAccountService m_UserAccountService; |
53 | private bool m_AllowCreateUser = false; | 53 | private bool m_AllowCreateUser = false; |
54 | private bool m_AllowSetAccount = false; | ||
54 | 55 | ||
55 | public UserAccountServerPostHandler(IUserAccountService service) | 56 | public UserAccountServerPostHandler(IUserAccountService service) |
56 | : this(service, null) {} | 57 | : this(service, null) {} |
@@ -61,7 +62,10 @@ namespace OpenSim.Server.Handlers.UserAccounts | |||
61 | m_UserAccountService = service; | 62 | m_UserAccountService = service; |
62 | 63 | ||
63 | if (config != null) | 64 | if (config != null) |
65 | { | ||
64 | m_AllowCreateUser = config.GetBoolean("AllowCreateUser", m_AllowCreateUser); | 66 | m_AllowCreateUser = config.GetBoolean("AllowCreateUser", m_AllowCreateUser); |
67 | m_AllowSetAccount = config.GetBoolean("AllowSetAccount", m_AllowSetAccount); | ||
68 | } | ||
65 | } | 69 | } |
66 | 70 | ||
67 | public override byte[] Handle(string path, Stream requestData, | 71 | public override byte[] Handle(string path, Stream requestData, |
@@ -99,8 +103,12 @@ namespace OpenSim.Server.Handlers.UserAccounts | |||
99 | case "getaccounts": | 103 | case "getaccounts": |
100 | return GetAccounts(request); | 104 | return GetAccounts(request); |
101 | case "setaccount": | 105 | case "setaccount": |
102 | return StoreAccount(request); | 106 | if (m_AllowSetAccount) |
107 | return StoreAccount(request); | ||
108 | else | ||
109 | break; | ||
103 | } | 110 | } |
111 | |||
104 | m_log.DebugFormat("[USER SERVICE HANDLER]: unknown method request: {0}", method); | 112 | m_log.DebugFormat("[USER SERVICE HANDLER]: unknown method request: {0}", method); |
105 | } | 113 | } |
106 | catch (Exception e) | 114 | catch (Exception e) |
@@ -193,8 +201,56 @@ namespace OpenSim.Server.Handlers.UserAccounts | |||
193 | 201 | ||
194 | byte[] StoreAccount(Dictionary<string, object> request) | 202 | byte[] StoreAccount(Dictionary<string, object> request) |
195 | { | 203 | { |
196 | // No can do. No changing user accounts from remote sims | 204 | UUID principalID = UUID.Zero; |
197 | return FailureResult(); | 205 | if (!(request.ContainsKey("UserID") && UUID.TryParse(request["UserID"].ToString(), out principalID))) |
206 | return FailureResult(); | ||
207 | |||
208 | UUID scopeID = UUID.Zero; | ||
209 | if (request.ContainsKey("ScopeID") && !UUID.TryParse(request["ScopeID"].ToString(), out scopeID)) | ||
210 | return FailureResult(); | ||
211 | |||
212 | UserAccount existingAccount = m_UserAccountService.GetUserAccount(scopeID, principalID); | ||
213 | if (existingAccount == null) | ||
214 | return FailureResult(); | ||
215 | |||
216 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
217 | |||
218 | if (request.ContainsKey("FirstName")) | ||
219 | existingAccount.FirstName = request["FirstName"].ToString(); | ||
220 | |||
221 | if (request.ContainsKey("LastName")) | ||
222 | existingAccount.LastName = request["LastName"].ToString(); | ||
223 | |||
224 | if (request.ContainsKey("Email")) | ||
225 | existingAccount.Email = request["Email"].ToString(); | ||
226 | |||
227 | int created = 0; | ||
228 | if (request.ContainsKey("Created") && int.TryParse(request["Created"].ToString(), out created)) | ||
229 | existingAccount.Created = created; | ||
230 | |||
231 | int userLevel = 0; | ||
232 | if (request.ContainsKey("UserLevel") && int.TryParse(request["UserLevel"].ToString(), out userLevel)) | ||
233 | existingAccount.UserFlags = userLevel; | ||
234 | |||
235 | int userFlags = 0; | ||
236 | if (request.ContainsKey("UserFlags") && int.TryParse(request["UserFlags"].ToString(), out userFlags)) | ||
237 | existingAccount.UserFlags = userFlags; | ||
238 | |||
239 | if (request.ContainsKey("UserTitle")) | ||
240 | existingAccount.UserTitle = request["UserTitle"].ToString(); | ||
241 | |||
242 | if (!m_UserAccountService.StoreUserAccount(existingAccount)) | ||
243 | { | ||
244 | m_log.ErrorFormat( | ||
245 | "[USER ACCOUNT SERVER POST HANDLER]: Account store failed for account {0} {1} {2}", | ||
246 | existingAccount.FirstName, existingAccount.LastName, existingAccount.PrincipalID); | ||
247 | |||
248 | return FailureResult(); | ||
249 | } | ||
250 | |||
251 | result["result"] = existingAccount.ToKeyValuePairs(); | ||
252 | |||
253 | return ResultToBytes(result); | ||
198 | } | 254 | } |
199 | 255 | ||
200 | byte[] CreateUser(Dictionary<string, object> request) | 256 | byte[] CreateUser(Dictionary<string, object> request) |
diff --git a/bin/Robust.HG.ini.example b/bin/Robust.HG.ini.example index 962c2f4..5958fc1 100644 --- a/bin/Robust.HG.ini.example +++ b/bin/Robust.HG.ini.example | |||
@@ -177,6 +177,10 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 | |||
177 | ;; Default is false. | 177 | ;; Default is false. |
178 | ; AllowCreateUser = false | 178 | ; AllowCreateUser = false |
179 | 179 | ||
180 | ;; Allow the service to process HTTP set account calls. | ||
181 | ;; Default is false. | ||
182 | ; AllowSetAccount = false | ||
183 | |||
180 | 184 | ||
181 | [GridUserService] | 185 | [GridUserService] |
182 | ; for the server connector | 186 | ; for the server connector |
diff --git a/bin/Robust.ini.example b/bin/Robust.ini.example index 661a15e..2c8770a 100644 --- a/bin/Robust.ini.example +++ b/bin/Robust.ini.example | |||
@@ -154,13 +154,16 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 | |||
154 | ;; This switch creates the minimum set of body parts and avatar entries for a viewer 2 | 154 | ;; This switch creates the minimum set of body parts and avatar entries for a viewer 2 |
155 | ;; to show a default "Ruth" avatar rather than a cloud for a newly created user. | 155 | ;; to show a default "Ruth" avatar rather than a cloud for a newly created user. |
156 | ;; Default is false | 156 | ;; Default is false |
157 | ;; If you enable this you will also need to uncomment the AvatarService line above | ||
158 | ; CreateDefaultAvatarEntries = false | 157 | ; CreateDefaultAvatarEntries = false |
159 | 158 | ||
160 | ;; Allow the service to process HTTP create user calls. | 159 | ;; Allow the service to process HTTP create user calls. |
161 | ;; Default is false. | 160 | ;; Default is false. |
162 | ; AllowCreateUser = false | 161 | ; AllowCreateUser = false |
163 | 162 | ||
163 | ;; Allow the service to process HTTP set account calls. | ||
164 | ;; Default is false. | ||
165 | ; AllowSetAccount = false | ||
166 | |||
164 | 167 | ||
165 | [GridUserService] | 168 | [GridUserService] |
166 | ; for the server connector | 169 | ; for the server connector |