summary refs log tree commit diff
path: root/synapse/module_api
diff options
context:
space:
mode:
authorBrendan Abolivier <babolivier@matrix.org>2020-03-03 10:54:44 +0000
committerBrendan Abolivier <babolivier@matrix.org>2020-03-03 10:54:44 +0000
commit65c73cdfec1876a9fec2fd2c3a74923cd146fe0b (patch)
tree9a348a434d7cd9493da3dc3ff306aa331fc0ad42 /synapse/module_api
parentMerge branch 'rav/sso-confirm-whitelist' into 'release-v1.11.1' (diff)
downloadsynapse-65c73cdfec1876a9fec2fd2c3a74923cd146fe0b.tar.xz
Factor out complete_sso_login and expose it to the Module API
Diffstat (limited to 'synapse/module_api')
-rw-r--r--synapse/module_api/__init__.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/synapse/module_api/__init__.py b/synapse/module_api/__init__.py
index d680ee95e1..c7fffd72f2 100644
--- a/synapse/module_api/__init__.py
+++ b/synapse/module_api/__init__.py
@@ -17,6 +17,7 @@ import logging
 
 from twisted.internet import defer
 
+from synapse.http.site import SynapseRequest
 from synapse.logging.context import make_deferred_yieldable, run_in_background
 from synapse.types import UserID
 
@@ -211,3 +212,21 @@ class ModuleApi(object):
             Deferred[object]: result of func
         """
         return self._store.db.runInteraction(desc, func, *args, **kwargs)
+
+    def complete_sso_login(
+        self, registered_user_id: str, request: SynapseRequest, client_redirect_url: str
+    ):
+        """Complete a SSO login by redirecting the user to a page to confirm whether they
+        want their access token sent to `client_redirect_url`, or redirect them to that
+        URL with a token directly if the URL matches with one of the whitelisted clients.
+
+        Args:
+            registered_user_id: The MXID that has been registered as a previous step of
+                of this SSO login.
+            request: The request to respond to.
+            client_redirect_url: The URL to which to offer to redirect the user (or to
+                redirect them directly if whitelisted).
+        """
+        self._auth_handler.complete_sso_login(
+            registered_user_id, request, client_redirect_url,
+        )