summary refs log tree commit diff
path: root/synapse/rest/client/v2_alpha/auth.py
diff options
context:
space:
mode:
Diffstat (limited to 'synapse/rest/client/v2_alpha/auth.py')
-rw-r--r--synapse/rest/client/v2_alpha/auth.py62
1 files changed, 25 insertions, 37 deletions
diff --git a/synapse/rest/client/v2_alpha/auth.py b/synapse/rest/client/v2_alpha/auth.py
index 8dfe5cba02..bebc2951e7 100644
--- a/synapse/rest/client/v2_alpha/auth.py
+++ b/synapse/rest/client/v2_alpha/auth.py
@@ -122,6 +122,7 @@ class AuthRestServlet(RestServlet):
     cannot be handled in the normal flow (with requests to the same endpoint).
     Current use is for web fallback auth.
     """
+
     PATTERNS = client_patterns(r"/auth/(?P<stagetype>[\w\.]*)/fallback/web")
 
     def __init__(self, hs):
@@ -138,11 +139,10 @@ class AuthRestServlet(RestServlet):
 
         if stagetype == LoginType.RECAPTCHA:
             html = RECAPTCHA_TEMPLATE % {
-                'session': session,
-                'myurl': "%s/r0/auth/%s/fallback/web" % (
-                    CLIENT_API_PREFIX, LoginType.RECAPTCHA
-                ),
-                'sitekey': self.hs.config.recaptcha_public_key,
+                "session": session,
+                "myurl": "%s/r0/auth/%s/fallback/web"
+                % (CLIENT_API_PREFIX, LoginType.RECAPTCHA),
+                "sitekey": self.hs.config.recaptcha_public_key,
             }
             html_bytes = html.encode("utf8")
             request.setResponseCode(200)
@@ -154,14 +154,11 @@ class AuthRestServlet(RestServlet):
             return None
         elif stagetype == LoginType.TERMS:
             html = TERMS_TEMPLATE % {
-                'session': session,
-                'terms_url': "%s_matrix/consent?v=%s" % (
-                    self.hs.config.public_baseurl,
-                    self.hs.config.user_consent_version,
-                ),
-                'myurl': "%s/r0/auth/%s/fallback/web" % (
-                    CLIENT_API_PREFIX, LoginType.TERMS
-                ),
+                "session": session,
+                "terms_url": "%s_matrix/consent?v=%s"
+                % (self.hs.config.public_baseurl, self.hs.config.user_consent_version),
+                "myurl": "%s/r0/auth/%s/fallback/web"
+                % (CLIENT_API_PREFIX, LoginType.TERMS),
             }
             html_bytes = html.encode("utf8")
             request.setResponseCode(200)
@@ -187,26 +184,20 @@ class AuthRestServlet(RestServlet):
             if not response:
                 raise SynapseError(400, "No captcha response supplied")
 
-            authdict = {
-                'response': response,
-                'session': session,
-            }
+            authdict = {"response": response, "session": session}
 
             success = yield self.auth_handler.add_oob_auth(
-                LoginType.RECAPTCHA,
-                authdict,
-                self.hs.get_ip_from_request(request)
+                LoginType.RECAPTCHA, authdict, self.hs.get_ip_from_request(request)
             )
 
             if success:
                 html = SUCCESS_TEMPLATE
             else:
                 html = RECAPTCHA_TEMPLATE % {
-                    'session': session,
-                    'myurl': "%s/r0/auth/%s/fallback/web" % (
-                        CLIENT_API_PREFIX, LoginType.RECAPTCHA
-                    ),
-                    'sitekey': self.hs.config.recaptcha_public_key,
+                    "session": session,
+                    "myurl": "%s/r0/auth/%s/fallback/web"
+                    % (CLIENT_API_PREFIX, LoginType.RECAPTCHA),
+                    "sitekey": self.hs.config.recaptcha_public_key,
                 }
             html_bytes = html.encode("utf8")
             request.setResponseCode(200)
@@ -218,31 +209,28 @@ class AuthRestServlet(RestServlet):
 
             defer.returnValue(None)
         elif stagetype == LoginType.TERMS:
-            if ('session' not in request.args or
-                    len(request.args['session'])) == 0:
+            if ("session" not in request.args or len(request.args["session"])) == 0:
                 raise SynapseError(400, "No session supplied")
 
-            session = request.args['session'][0]
-            authdict = {'session': session}
+            session = request.args["session"][0]
+            authdict = {"session": session}
 
             success = yield self.auth_handler.add_oob_auth(
-                LoginType.TERMS,
-                authdict,
-                self.hs.get_ip_from_request(request)
+                LoginType.TERMS, authdict, self.hs.get_ip_from_request(request)
             )
 
             if success:
                 html = SUCCESS_TEMPLATE
             else:
                 html = TERMS_TEMPLATE % {
-                    'session': session,
-                    'terms_url': "%s_matrix/consent?v=%s" % (
+                    "session": session,
+                    "terms_url": "%s_matrix/consent?v=%s"
+                    % (
                         self.hs.config.public_baseurl,
                         self.hs.config.user_consent_version,
                     ),
-                    'myurl': "%s/r0/auth/%s/fallback/web" % (
-                        CLIENT_API_PREFIX, LoginType.TERMS
-                    ),
+                    "myurl": "%s/r0/auth/%s/fallback/web"
+                    % (CLIENT_API_PREFIX, LoginType.TERMS),
                 }
             html_bytes = html.encode("utf8")
             request.setResponseCode(200)