aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-10-19 19:01:57 +0100
committerJustin Clark-Casey (justincc)2011-10-19 19:03:17 +0100
commitd9184eceab5ff9087801b0f0d447dec2f5227a50 (patch)
tree18f4a8125c67fd86db53106f798b52296bb44ab3 /OpenSim/Server
parentSlightly change log message in LoadRegionsPlugin (diff)
downloadopensim-SC_OLD-d9184eceab5ff9087801b0f0d447dec2f5227a50.zip
opensim-SC_OLD-d9184eceab5ff9087801b0f0d447dec2f5227a50.tar.gz
opensim-SC_OLD-d9184eceab5ff9087801b0f0d447dec2f5227a50.tar.bz2
opensim-SC_OLD-d9184eceab5ff9087801b0f0d447dec2f5227a50.tar.xz
Add option to allow remote http calls to setpassword in the AuthenticationService.
This is switched on by setting AllowSetPassword = true in the [AuthenticationService] section of Robust.ini or Robust.HG.ini Default is false as before.
Diffstat (limited to 'OpenSim/Server')
-rw-r--r--OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs2
-rw-r--r--OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs67
2 files changed, 46 insertions, 23 deletions
diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs
index adb1e5b..848a037 100644
--- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs
+++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerConnector.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Server.Handlers.Authentication
58 Object[] args = new Object[] { config }; 58 Object[] args = new Object[] { config };
59 m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authenticationService, args); 59 m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authenticationService, args);
60 60
61 server.AddStreamHandler(new AuthenticationServerPostHandler(m_AuthenticationService)); 61 server.AddStreamHandler(new AuthenticationServerPostHandler(m_AuthenticationService, serverConfig));
62 } 62 }
63 } 63 }
64} 64}
diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
index 47bc860..ae71945 100644
--- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
@@ -49,11 +49,20 @@ namespace OpenSim.Server.Handlers.Authentication
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 private bool m_AllowSetPassword = false;
52 53
53 public AuthenticationServerPostHandler(IAuthenticationService service) : 54 public AuthenticationServerPostHandler(IAuthenticationService service) :
55 this(service, null) {}
56
57 public AuthenticationServerPostHandler(IAuthenticationService service, IConfig config) :
54 base("POST", "/auth") 58 base("POST", "/auth")
55 { 59 {
56 m_AuthenticationService = service; 60 m_AuthenticationService = service;
61
62 if (config != null)
63 {
64 m_AllowSetPassword = config.GetBoolean("AllowSetPassword", m_AllowSetPassword);
65 }
57 } 66 }
58 67
59 public override byte[] Handle(string path, Stream request, 68 public override byte[] Handle(string path, Stream request,
@@ -113,31 +122,45 @@ namespace OpenSim.Server.Handlers.Authentication
113 122
114 switch (method) 123 switch (method)
115 { 124 {
116 case "authenticate": 125 case "authenticate":
117 if (!request.ContainsKey("PASSWORD")) 126 if (!request.ContainsKey("PASSWORD"))
127 return FailureResult();
128
129 token = m_AuthenticationService.Authenticate(principalID, request["PASSWORD"].ToString(), lifetime);
130
131 if (token != String.Empty)
132 return SuccessResult(token);
118 return FailureResult(); 133 return FailureResult();
119 134
120 token = m_AuthenticationService.Authenticate(principalID, request["PASSWORD"].ToString(), lifetime); 135 case "setpassword":
121 136 if (!m_AllowSetPassword)
122 if (token != String.Empty) 137 return FailureResult();
123 return SuccessResult(token); 138
124 return FailureResult(); 139 if (!request.ContainsKey("PASSWORD"))
125 case "verify": 140 return FailureResult();
126 if (!request.ContainsKey("TOKEN")) 141
142 if (m_AuthenticationService.SetPassword(principalID, request["PASSWORD"].ToString()))
143 return SuccessResult();
144 else
145 return FailureResult();
146
147 case "verify":
148 if (!request.ContainsKey("TOKEN"))
149 return FailureResult();
150
151 if (m_AuthenticationService.Verify(principalID, request["TOKEN"].ToString(), lifetime))
152 return SuccessResult();
153
127 return FailureResult(); 154 return FailureResult();
128 155
129 if (m_AuthenticationService.Verify(principalID, request["TOKEN"].ToString(), lifetime)) 156 case "release":
130 return SuccessResult(); 157 if (!request.ContainsKey("TOKEN"))
131 158 return FailureResult();
132 return FailureResult(); 159
133 case "release": 160 if (m_AuthenticationService.Release(principalID, request["TOKEN"].ToString()))
134 if (!request.ContainsKey("TOKEN")) 161 return SuccessResult();
162
135 return FailureResult(); 163 return FailureResult();
136
137 if (m_AuthenticationService.Release(principalID, request["TOKEN"].ToString()))
138 return SuccessResult();
139
140 return FailureResult();
141 } 164 }
142 165
143 return FailureResult(); 166 return FailureResult();