diff options
author | Melanie Thielker | 2009-06-30 21:48:03 +0000 |
---|---|---|
committer | Melanie Thielker | 2009-06-30 21:48:03 +0000 |
commit | 858b0a2efd4790042c3e248ce895a426462a2576 (patch) | |
tree | 2d9e9f61b5ca0219537e6debbcf75c703be52854 /OpenSim | |
parent | From: Chris Yeoh <yeohc@au1.ibm.com> (diff) | |
download | opensim-SC-858b0a2efd4790042c3e248ce895a426462a2576.zip opensim-SC-858b0a2efd4790042c3e248ce895a426462a2576.tar.gz opensim-SC-858b0a2efd4790042c3e248ce895a426462a2576.tar.bz2 opensim-SC-858b0a2efd4790042c3e248ce895a426462a2576.tar.xz |
Updated services to allow external applications like web interfaces to
authenticate against the services. This paves the way for such apps
to directly talk to services.
Diffstat (limited to '')
5 files changed, 228 insertions, 24 deletions
diff --git a/OpenSim/Services/AuthenticationService/AuthenticationService.cs b/OpenSim/Services/AuthenticationService/AuthenticationService.cs index 06f0e8f..3e6c3b2 100644 --- a/OpenSim/Services/AuthenticationService/AuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/AuthenticationService.cs | |||
@@ -98,16 +98,70 @@ namespace OpenSim.Services.AuthenticationService | |||
98 | m_Database.Initialise(connString); | 98 | m_Database.Initialise(connString); |
99 | } | 99 | } |
100 | 100 | ||
101 | public UUID AuthenticateKey(UUID principalID, string key) | ||
102 | { | ||
103 | bool writeAgentData = false; | ||
104 | |||
105 | UserAgentData agent = m_Database.GetAgentByUUID(principalID); | ||
106 | if (agent == null) | ||
107 | { | ||
108 | agent = new UserAgentData(); | ||
109 | agent.ProfileID = principalID; | ||
110 | agent.SessionID = UUID.Random(); | ||
111 | agent.SecureSessionID = UUID.Random(); | ||
112 | agent.AgentIP = "127.0.0.1"; | ||
113 | agent.AgentPort = 0; | ||
114 | agent.AgentOnline = false; | ||
115 | |||
116 | writeAgentData = true; | ||
117 | } | ||
118 | |||
119 | if (!m_PerformAuthentication) | ||
120 | { | ||
121 | if (writeAgentData) | ||
122 | m_Database.AddNewUserAgent(agent); | ||
123 | return agent.SessionID; | ||
124 | } | ||
125 | |||
126 | if (!VerifyKey(principalID, key)) | ||
127 | return UUID.Zero; | ||
128 | |||
129 | if (writeAgentData) | ||
130 | m_Database.AddNewUserAgent(agent); | ||
131 | |||
132 | return agent.SessionID; | ||
133 | } | ||
134 | |||
101 | /// <summary> | 135 | /// <summary> |
102 | /// This implementation only authenticates users. | 136 | /// This implementation only authenticates users. |
103 | /// </summary> | 137 | /// </summary> |
104 | /// <param name="principalID"></param> | 138 | /// <param name="principalID"></param> |
105 | /// <param name="password"></param> | 139 | /// <param name="password"></param> |
106 | /// <returns></returns> | 140 | /// <returns></returns> |
107 | public bool Authenticate(UUID principalID, string password) | 141 | public UUID AuthenticatePassword(UUID principalID, string password) |
108 | { | 142 | { |
143 | bool writeAgentData = false; | ||
144 | |||
145 | UserAgentData agent = m_Database.GetAgentByUUID(principalID); | ||
146 | if (agent == null) | ||
147 | { | ||
148 | agent = new UserAgentData(); | ||
149 | agent.ProfileID = principalID; | ||
150 | agent.SessionID = UUID.Random(); | ||
151 | agent.SecureSessionID = UUID.Random(); | ||
152 | agent.AgentIP = "127.0.0.1"; | ||
153 | agent.AgentPort = 0; | ||
154 | agent.AgentOnline = false; | ||
155 | |||
156 | writeAgentData = true; | ||
157 | } | ||
158 | |||
109 | if (!m_PerformAuthentication) | 159 | if (!m_PerformAuthentication) |
110 | return true; | 160 | { |
161 | if (writeAgentData) | ||
162 | m_Database.AddNewUserAgent(agent); | ||
163 | return agent.SessionID; | ||
164 | } | ||
111 | 165 | ||
112 | UserProfileData profile = m_Database.GetUserByUUID(principalID); | 166 | UserProfileData profile = m_Database.GetUserByUUID(principalID); |
113 | bool passwordSuccess = false; | 167 | bool passwordSuccess = false; |
@@ -128,7 +182,13 @@ namespace OpenSim.Services.AuthenticationService | |||
128 | passwordSuccess = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) | 182 | passwordSuccess = (profile.PasswordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase) |
129 | || profile.PasswordHash.Equals(password, StringComparison.InvariantCulture)); | 183 | || profile.PasswordHash.Equals(password, StringComparison.InvariantCulture)); |
130 | 184 | ||
131 | return passwordSuccess; | 185 | if (!passwordSuccess) |
186 | return UUID.Zero; | ||
187 | |||
188 | if (writeAgentData) | ||
189 | m_Database.AddNewUserAgent(agent); | ||
190 | |||
191 | return agent.SessionID; | ||
132 | } | 192 | } |
133 | 193 | ||
134 | /// <summary> | 194 | /// <summary> |
@@ -203,10 +263,17 @@ namespace OpenSim.Services.AuthenticationService | |||
203 | } | 263 | } |
204 | } | 264 | } |
205 | 265 | ||
206 | public UUID AllocateUserSession(UUID userID) | 266 | public UUID CreateUserSession(UUID userID, UUID oldSessionID) |
207 | { | 267 | { |
208 | // Not implemented yet | 268 | UserAgentData agent = m_Database.GetAgentByUUID(userID); |
209 | return UUID.Zero; | 269 | |
270 | if (agent == null) | ||
271 | return UUID.Zero; | ||
272 | |||
273 | agent.SessionID = UUID.Random(); | ||
274 | |||
275 | m_Database.AddNewUserAgent(agent); | ||
276 | return agent.SessionID; | ||
210 | } | 277 | } |
211 | 278 | ||
212 | public bool VerifyUserSession(UUID userID, UUID sessionID) | 279 | public bool VerifyUserSession(UUID userID, UUID sessionID) |
@@ -225,9 +292,19 @@ namespace OpenSim.Services.AuthenticationService | |||
225 | return false; | 292 | return false; |
226 | } | 293 | } |
227 | 294 | ||
228 | public void DestroyUserSession(UUID userID) | 295 | public bool DestroyUserSession(UUID userID, UUID sessionID) |
229 | { | 296 | { |
230 | // Not implemented yet | 297 | if (!VerifyUserSession(userID, sessionID)) |
298 | return false; | ||
299 | |||
300 | UserAgentData agent = m_Database.GetAgentByUUID(userID); | ||
301 | if (agent == null) | ||
302 | return false; | ||
303 | |||
304 | agent.SessionID = UUID.Zero; | ||
305 | m_Database.AddNewUserAgent(agent); | ||
306 | |||
307 | return true; | ||
231 | } | 308 | } |
232 | } | 309 | } |
233 | } | 310 | } |
diff --git a/OpenSim/Services/Connectors/User/UserServiceConnector.cs b/OpenSim/Services/Connectors/User/UserServiceConnector.cs index 8b136b5..12afb29 100644 --- a/OpenSim/Services/Connectors/User/UserServiceConnector.cs +++ b/OpenSim/Services/Connectors/User/UserServiceConnector.cs | |||
@@ -133,15 +133,71 @@ namespace OpenSim.Services.Connectors | |||
133 | return data; | 133 | return data; |
134 | } | 134 | } |
135 | 135 | ||
136 | public bool SetUserData(UserData data) | 136 | public bool SetHomePosition(UserData data, UUID regionID, UUID regionSecret) |
137 | { | 137 | { |
138 | string uri = m_ServerURI + "/user/"; | 138 | string uri = m_ServerURI + "/user/"; |
139 | bool result = false; | 139 | bool result = false; |
140 | 140 | ||
141 | UserDataMessage msg = new UserDataMessage(); | ||
142 | |||
143 | msg.Data = data; | ||
144 | msg.RegionID = regionID; | ||
145 | msg.RegionSecret = regionSecret; | ||
146 | |||
147 | try | ||
148 | { | ||
149 | result = SynchronousRestObjectRequester. | ||
150 | MakeRequest<UserDataMessage, bool>("POST", uri, msg); | ||
151 | } | ||
152 | catch (Exception e) | ||
153 | { | ||
154 | m_log.WarnFormat("[USER CONNECTOR]: Unable to send request to user server. Reason: {1}", e.Message); | ||
155 | return false; | ||
156 | } | ||
157 | |||
158 | return result; | ||
159 | } | ||
160 | |||
161 | public bool SetUserData(UserData data, UUID principalID, UUID sessionID) | ||
162 | { | ||
163 | string uri = m_ServerURI + "/user/"; | ||
164 | bool result = false; | ||
165 | |||
166 | UserDataMessage msg = new UserDataMessage(); | ||
167 | |||
168 | msg.Data = data; | ||
169 | msg.PrincipalID = principalID; | ||
170 | msg.SessionID = sessionID; | ||
171 | |||
172 | try | ||
173 | { | ||
174 | result = SynchronousRestObjectRequester. | ||
175 | MakeRequest<UserDataMessage, bool>("POST", uri, msg); | ||
176 | } | ||
177 | catch (Exception e) | ||
178 | { | ||
179 | m_log.WarnFormat("[USER CONNECTOR]: Unable to send request to user server. Reason: {1}", e.Message); | ||
180 | return false; | ||
181 | } | ||
182 | |||
183 | return result; | ||
184 | } | ||
185 | |||
186 | public bool CreateUserData(UserData data, UUID principalID, UUID sessionID) | ||
187 | { | ||
188 | string uri = m_ServerURI + "/newuser/"; | ||
189 | bool result = false; | ||
190 | |||
191 | UserDataMessage msg = new UserDataMessage(); | ||
192 | |||
193 | msg.Data = data; | ||
194 | msg.PrincipalID = principalID; | ||
195 | msg.SessionID = sessionID; | ||
196 | |||
141 | try | 197 | try |
142 | { | 198 | { |
143 | result = SynchronousRestObjectRequester. | 199 | result = SynchronousRestObjectRequester. |
144 | MakeRequest<UserData, bool>("POST", uri, data); | 200 | MakeRequest<UserDataMessage, bool>("POST", uri, msg); |
145 | } | 201 | } |
146 | catch (Exception e) | 202 | catch (Exception e) |
147 | { | 203 | { |
diff --git a/OpenSim/Services/Interfaces/IAuthenticationService.cs b/OpenSim/Services/Interfaces/IAuthenticationService.cs index fa45cbc..2402414 100644 --- a/OpenSim/Services/Interfaces/IAuthenticationService.cs +++ b/OpenSim/Services/Interfaces/IAuthenticationService.cs | |||
@@ -38,9 +38,9 @@ namespace OpenSim.Services.Interfaces | |||
38 | // | 38 | // |
39 | public interface IAuthenticationService | 39 | public interface IAuthenticationService |
40 | { | 40 | { |
41 | // Check the pricipal's password | 41 | ////////////////////////////////////////////////// |
42 | // Web login key portion | ||
42 | // | 43 | // |
43 | bool Authenticate(UUID principalID, string password); | ||
44 | 44 | ||
45 | // Get a service key given that principal's | 45 | // Get a service key given that principal's |
46 | // authentication token (master key). | 46 | // authentication token (master key). |
@@ -51,18 +51,44 @@ namespace OpenSim.Services.Interfaces | |||
51 | // | 51 | // |
52 | bool VerifyKey(UUID principalID, string key); | 52 | bool VerifyKey(UUID principalID, string key); |
53 | 53 | ||
54 | // Create a new user session. If one exists, it is cleared | 54 | ////////////////////////////////////////////////// |
55 | // | 55 | // Password auth portion |
56 | UUID AllocateUserSession(UUID userID); | 56 | // |
57 | |||
58 | // Here's how thos works, and why. | ||
59 | // | ||
60 | // The authentication methods will return the existing session, | ||
61 | // or UUID.Zero if authentication failed. If there is no session, | ||
62 | // they will create one. | ||
63 | // The CreateUserSession method will unconditionally create a session | ||
64 | // and invalidate the prior session. | ||
65 | // Grid login uses this method to make sure that the session is | ||
66 | // fresh and new. Other software, like management applications, | ||
67 | // can obtain this existing session if they have a key or password | ||
68 | // for that account, this allows external apps to obtain credentials | ||
69 | // and use authenticating interface methods. | ||
70 | // | ||
71 | |||
72 | // Check the pricipal's password | ||
73 | // | ||
74 | UUID AuthenticatePassword(UUID principalID, string password); | ||
75 | |||
76 | // Check the principal's key | ||
77 | // | ||
78 | UUID AuthenticateKey(UUID principalID, string password); | ||
79 | |||
80 | // Create a new session, invalidating the old ones | ||
81 | // | ||
82 | UUID CreateUserSession(UUID principalID, UUID oldSessionID); | ||
57 | 83 | ||
58 | // Verify that a user session ID is valid. A session ID is | 84 | // Verify that a user session ID is valid. A session ID is |
59 | // considered valid when a user has successfully authenticated | 85 | // considered valid when a user has successfully authenticated |
60 | // at least one time inside that session. | 86 | // at least one time inside that session. |
61 | // | 87 | // |
62 | bool VerifyUserSession(UUID principalID, UUID session); | 88 | bool VerifyUserSession(UUID principalID, UUID sessionID); |
63 | 89 | ||
64 | // Remove a user session identifier and deauthenticate the user | 90 | // Deauthenticate user |
65 | // | 91 | // |
66 | void DestroyUserSession(UUID principalID); | 92 | bool DestroyUserSession(UUID principalID, UUID sessionID); |
67 | } | 93 | } |
68 | } | 94 | } |
diff --git a/OpenSim/Services/Interfaces/IUserService.cs b/OpenSim/Services/Interfaces/IUserService.cs index 2a4e79d..9bbe503 100644 --- a/OpenSim/Services/Interfaces/IUserService.cs +++ b/OpenSim/Services/Interfaces/IUserService.cs | |||
@@ -32,6 +32,24 @@ namespace OpenSim.Services.Interfaces | |||
32 | { | 32 | { |
33 | public class UserData | 33 | public class UserData |
34 | { | 34 | { |
35 | public UserData() | ||
36 | { | ||
37 | } | ||
38 | |||
39 | public UserData(UUID userID, UUID homeRegionID, float homePositionX, | ||
40 | float homePositionY, float homePositionZ, float homeLookAtX, | ||
41 | float homeLookAtY, float homeLookAtZ) | ||
42 | { | ||
43 | UserID = userID; | ||
44 | HomeRegionID = homeRegionID; | ||
45 | HomePositionX = homePositionX; | ||
46 | HomePositionY = homePositionY; | ||
47 | HomePositionZ = homePositionZ; | ||
48 | HomeLookAtX = homeLookAtX; | ||
49 | HomeLookAtY = homeLookAtY; | ||
50 | HomeLookAtZ = homeLookAtZ; | ||
51 | } | ||
52 | |||
35 | public string FirstName; | 53 | public string FirstName; |
36 | public string LastName; | 54 | public string LastName; |
37 | public UUID UserID; | 55 | public UUID UserID; |
@@ -49,7 +67,7 @@ namespace OpenSim.Services.Interfaces | |||
49 | public float HomeLookAtY; | 67 | public float HomeLookAtY; |
50 | public float HomeLookAtZ; | 68 | public float HomeLookAtZ; |
51 | 69 | ||
52 | // There are here because they | 70 | // These are here because they |
53 | // concern the account rather than | 71 | // concern the account rather than |
54 | // the profile. They just happen to | 72 | // the profile. They just happen to |
55 | // be used in the Linden profile as well | 73 | // be used in the Linden profile as well |
@@ -58,11 +76,21 @@ namespace OpenSim.Services.Interfaces | |||
58 | public int UserFlags; | 76 | public int UserFlags; |
59 | public string AccountType; | 77 | public string AccountType; |
60 | 78 | ||
61 | // This is only used internally. It needs to be set | 79 | }; |
62 | // to the secret of the sending region when updating | 80 | |
63 | // user data. | 81 | public class UserDataMessage |
82 | { | ||
83 | public UserData Data; | ||
84 | |||
85 | // Set to the region's ID and secret when updating home location | ||
64 | // | 86 | // |
87 | public UUID RegionID; | ||
65 | public UUID RegionSecret; | 88 | public UUID RegionSecret; |
89 | |||
90 | // Set to the auth info of the user requesting creation/update | ||
91 | // | ||
92 | public UUID PrincipalID; | ||
93 | public UUID SessionID; | ||
66 | }; | 94 | }; |
67 | 95 | ||
68 | public interface IUserDataService | 96 | public interface IUserDataService |
@@ -73,11 +101,18 @@ namespace OpenSim.Services.Interfaces | |||
73 | // This will set only the home region portion of the data! | 101 | // This will set only the home region portion of the data! |
74 | // Can't be used to set god level, flags, type or change the name! | 102 | // Can't be used to set god level, flags, type or change the name! |
75 | // | 103 | // |
76 | bool SetUserData(UserData data); | 104 | bool SetHomePosition(UserData data, UUID RegionID, UUID RegionSecret); |
105 | |||
106 | // Update all updatable fields | ||
107 | // | ||
108 | bool SetUserData(UserData data, UUID PrincipalID, UUID SessionID); | ||
77 | 109 | ||
78 | // Returns the list of avatars that matches both the search | 110 | // Returns the list of avatars that matches both the search |
79 | // criterion and the scope ID passed | 111 | // criterion and the scope ID passed |
80 | // | 112 | // |
81 | List<UserData> GetAvatarPickerData(UUID scopeID, string query); | 113 | List<UserData> GetAvatarPickerData(UUID scopeID, string query); |
114 | |||
115 | // Creates a user data record | ||
116 | bool CreateUserData(UserData data, UUID PrincipalID, UUID SessionID); | ||
82 | } | 117 | } |
83 | } | 118 | } |
diff --git a/OpenSim/Services/UserService/UserService.cs b/OpenSim/Services/UserService/UserService.cs index 5a6e5fb..cfbc2c1 100644 --- a/OpenSim/Services/UserService/UserService.cs +++ b/OpenSim/Services/UserService/UserService.cs | |||
@@ -52,7 +52,17 @@ namespace OpenSim.Services.UserService | |||
52 | return null; | 52 | return null; |
53 | } | 53 | } |
54 | 54 | ||
55 | public bool SetUserData(UserData data) | 55 | public bool SetHomePosition(UserData data, UUID regionID, UUID regionSecret) |
56 | { | ||
57 | return false; | ||
58 | } | ||
59 | |||
60 | public bool SetUserData(UserData data, UUID principalID, UUID sessionID) | ||
61 | { | ||
62 | return false; | ||
63 | } | ||
64 | |||
65 | public bool CreateUserData(UserData data, UUID principalID, UUID sessionID) | ||
56 | { | 66 | { |
57 | return false; | 67 | return false; |
58 | } | 68 | } |