summary refs log tree commit diff
path: root/synapse/rest/client
diff options
context:
space:
mode:
authorSteven Hammerton <steven.hammerton@openmarket.com>2015-10-09 11:02:56 +0100
committerSteven Hammerton <steven.hammerton@openmarket.com>2015-10-10 10:54:19 +0100
commit625e13bfde35a3c6fdd2b3e8263838ec4d4fbcc3 (patch)
tree7004ac619e80d4e8cebb697fdb179baf9d85e739 /synapse/rest/client
parentFormatting changes (diff)
downloadsynapse-625e13bfde35a3c6fdd2b3e8263838ec4d4fbcc3.tar.xz
Add get_raw method to SimpleHttpClient, use this in CAS auth rather than requests
Diffstat (limited to 'synapse/rest/client')
-rw-r--r--synapse/rest/client/v1/login.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/synapse/rest/client/v1/login.py b/synapse/rest/client/v1/login.py
index 4de5f19591..f5cd6a1960 100644
--- a/synapse/rest/client/v1/login.py
+++ b/synapse/rest/client/v1/login.py
@@ -16,6 +16,7 @@
 from twisted.internet import defer
 
 from synapse.api.errors import SynapseError, LoginError, Codes
+from synapse.http.client import SimpleHttpClient
 from synapse.types import UserID
 from base import ClientV1RestServlet, client_path_pattern
 
@@ -28,7 +29,6 @@ from saml2 import config
 from saml2.client import Saml2Client
 
 import xml.etree.ElementTree as ET
-import requests
 
 
 logger = logging.getLogger(__name__)
@@ -79,13 +79,16 @@ class LoginRestServlet(ClientV1RestServlet):
                 defer.returnValue((200, result))
             elif self.cas_enabled and (login_submission["type"] ==
                                        LoginRestServlet.CAS_TYPE):
-                url = "%s/proxyValidate" % (self.cas_server_url)
-                parameters = {
+                # TODO: get this from the homeserver rather than creating a new one for
+                # each request
+                http_client = SimpleHttpClient(self.hs)
+                uri = "%s/proxyValidate" % (self.cas_server_url,)
+                args = {
                     "ticket": login_submission["ticket"],
                     "service": login_submission["service"]
                 }
-                response = requests.get(url, verify=False, params=parameters)
-                result = yield self.do_cas_login(response.text)
+                body = yield http_client.get_raw(uri, args)
+                result = yield self.do_cas_login(body)
                 defer.returnValue(result)
             else:
                 raise SynapseError(400, "Bad login type.")