From e377d3365293a25a9f4d38706da60f2c221fdf89 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 20 Nov 2014 17:41:56 +0000 Subject: Separate out the matrix http client completely because just about all of its code it now separate from the simple case we need for standard HTTP(S) --- synapse/rest/register.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'synapse/rest') diff --git a/synapse/rest/register.py b/synapse/rest/register.py index 5c15614ea9..a51f77034a 100644 --- a/synapse/rest/register.py +++ b/synapse/rest/register.py @@ -222,6 +222,7 @@ class RegisterRestServlet(RestServlet): threepidCreds = register_json['threepidCreds'] handler = self.handlers.registration_handler + logger.debug("Registering email. threepidcreds: %s" % (threepidCreds)) yield handler.register_email(threepidCreds) session["threepidCreds"] = threepidCreds # store creds for next stage session[LoginType.EMAIL_IDENTITY] = True # mark email as done @@ -232,6 +233,7 @@ class RegisterRestServlet(RestServlet): @defer.inlineCallbacks def _do_password(self, request, register_json, session): + yield if (self.hs.config.enable_registration_captcha and not session[LoginType.RECAPTCHA]): # captcha should've been done by this stage! @@ -259,6 +261,7 @@ class RegisterRestServlet(RestServlet): ) if session[LoginType.EMAIL_IDENTITY]: + logger.debug("Binding emails %s to %s" % (session["threepidCreds"], user_id)) yield handler.bind_emails(user_id, session["threepidCreds"]) result = { -- cgit 1.4.1 From 610c2ea1314a8aeb0a5c3b8a06f67a4057e25a4c Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Thu, 20 Nov 2014 18:00:10 +0000 Subject: Fix pep8 and pyflakes warnings --- synapse/handlers/login.py | 5 +++-- synapse/handlers/register.py | 9 +++++++-- synapse/http/client.py | 7 ++++--- synapse/http/endpoint.py | 2 +- synapse/http/matrixfederationclient.py | 6 +++--- synapse/rest/register.py | 4 +++- 6 files changed, 21 insertions(+), 12 deletions(-) (limited to 'synapse/rest') diff --git a/synapse/handlers/login.py b/synapse/handlers/login.py index 979086a3d6..c98ae2cfb5 100644 --- a/synapse/handlers/login.py +++ b/synapse/handlers/login.py @@ -23,7 +23,6 @@ import synapse.util.emailutils as emailutils import bcrypt import logging -import urllib logger = logging.getLogger(__name__) @@ -101,7 +100,9 @@ class LoginHandler(BaseHandler): data = yield httpCli.get_json( # TODO FIXME This should be configurable. # XXX: ID servers need to use HTTPS - "http://%s%s" % ("matrix.org:8090", "/_matrix/identity/api/v1/lookup"), + "http://%s%s" % ( + "matrix.org:8090", "/_matrix/identity/api/v1/lookup" + ), { 'medium': 'email', 'address': email diff --git a/synapse/handlers/register.py b/synapse/handlers/register.py index 277616ea69..48c326ebf0 100644 --- a/synapse/handlers/register.py +++ b/synapse/handlers/register.py @@ -168,7 +168,10 @@ class RegistrationHandler(BaseHandler): defer.returnValue(None) data = yield httpCli.get_json( # XXX: This should be HTTPS - "http://%s%s" % (creds['idServer'], "/_matrix/identity/api/v1/3pid/getValidated3pid"), + "http://%s%s" % ( + creds['idServer'], + "/_matrix/identity/api/v1/3pid/getValidated3pid" + ), {'sid': creds['sid'], 'clientSecret': creds['clientSecret']} ) @@ -183,7 +186,9 @@ class RegistrationHandler(BaseHandler): httpCli = SimpleHttpClient(self.hs) data = yield httpCli.post_urlencoded_get_json( # XXX: Change when ID servers are all HTTPS - "http://%s%s" % (creds['idServer'], "/_matrix/identity/api/v1/3pid/bind"), + "http://%s%s" % ( + creds['idServer'], "/_matrix/identity/api/v1/3pid/bind" + ), { 'sid': creds['sid'], 'clientSecret': creds['clientSecret'], diff --git a/synapse/http/client.py b/synapse/http/client.py index 5c3ddcd83d..048a428905 100644 --- a/synapse/http/client.py +++ b/synapse/http/client.py @@ -32,15 +32,16 @@ logger = logging.getLogger(__name__) class SimpleHttpClient(object): """ - A simple, no-frills HTTP client with methods that wrap up common ways of using HTTP in Matrix + A simple, no-frills HTTP client with methods that wrap up common ways of + using HTTP in Matrix """ def __init__(self, hs): self.hs = hs # The default context factory in Twisted 14.0.0 (which we require) is - # BrowserLikePolicyForHTTPS which will do regular cert validation 'like a browser' + # BrowserLikePolicyForHTTPS which will do regular cert validation + # 'like a browser' self.agent = Agent(reactor) - @defer.inlineCallbacks def post_urlencoded_get_json(self, uri, args={}): logger.debug("post_urlencoded_get_json args: %s", args) diff --git a/synapse/http/endpoint.py b/synapse/http/endpoint.py index f1b14a5657..9c8888f565 100644 --- a/synapse/http/endpoint.py +++ b/synapse/http/endpoint.py @@ -28,7 +28,7 @@ logger = logging.getLogger(__name__) def matrix_federation_endpoint(reactor, destination, ssl_context_factory=None, - timeout=None): + timeout=None): """Construct an endpoint for the given matrix destination. Args: diff --git a/synapse/http/matrixfederationclient.py b/synapse/http/matrixfederationclient.py index b179c76496..510f07dd7b 100644 --- a/synapse/http/matrixfederationclient.py +++ b/synapse/http/matrixfederationclient.py @@ -62,8 +62,8 @@ class MatrixFederationHttpAgent(_AgentBase): class MatrixFederationHttpClient(object): - """HTTP client used to talk to other homeservers over the federation protocol. - Send client certificates and signs requests. + """HTTP client used to talk to other homeservers over the federation + protocol. Send client certificates and signs requests. Attributes: agent (twisted.web.client.Agent): The twisted Agent used to send the @@ -305,4 +305,4 @@ class _JsonProducer(object): pass def stopProducing(self): - pass \ No newline at end of file + pass diff --git a/synapse/rest/register.py b/synapse/rest/register.py index a51f77034a..f25e23a158 100644 --- a/synapse/rest/register.py +++ b/synapse/rest/register.py @@ -261,7 +261,9 @@ class RegisterRestServlet(RestServlet): ) if session[LoginType.EMAIL_IDENTITY]: - logger.debug("Binding emails %s to %s" % (session["threepidCreds"], user_id)) + logger.debug("Binding emails %s to %s" % ( + session["threepidCreds"], user_id) + ) yield handler.bind_emails(user_id, session["threepidCreds"]) result = { -- cgit 1.4.1