summary refs log tree commit diff
diff options
context:
space:
mode:
authorJason Robinson <jasonr@matrix.org>2020-03-26 22:10:31 +0200
committerGitHub <noreply@github.com>2020-03-26 22:10:31 +0200
commit7496d3d2f6b254ace7a483c286a61c327f2f301f (patch)
treeb6002239641a7e2ccab4a943de28f01e312250aa
parentRefactor the CAS code (move the logic out of the REST layer to a handler) (#7... (diff)
parentUpdate changelog.d/7151.bugfix (diff)
downloadsynapse-7496d3d2f6b254ace7a483c286a61c327f2f301f.tar.xz
Merge pull request #7151 from matrix-org/jaywink/saml-redirect-fix
Allow RedirectResponse in SAML response handler
-rw-r--r--changelog.d/7151.bugfix1
-rw-r--r--synapse/handlers/saml_handler.py4
2 files changed, 5 insertions, 0 deletions
diff --git a/changelog.d/7151.bugfix b/changelog.d/7151.bugfix
new file mode 100644
index 0000000000..8aaa2dc659
--- /dev/null
+++ b/changelog.d/7151.bugfix
@@ -0,0 +1 @@
+Fix error page being shown when a custom SAML handler attempted to redirect when processing an auth response.
diff --git a/synapse/handlers/saml_handler.py b/synapse/handlers/saml_handler.py
index 72c109981b..dc04b53f43 100644
--- a/synapse/handlers/saml_handler.py
+++ b/synapse/handlers/saml_handler.py
@@ -26,6 +26,7 @@ from synapse.config import ConfigError
 from synapse.http.server import finish_request
 from synapse.http.servlet import parse_string
 from synapse.module_api import ModuleApi
+from synapse.module_api.errors import RedirectException
 from synapse.types import (
     UserID,
     map_username_to_mxid_localpart,
@@ -119,6 +120,9 @@ class SamlHandler:
 
         try:
             user_id = await self._map_saml_response_to_user(resp_bytes, relay_state)
+        except RedirectException:
+            # Raise the exception as per the wishes of the SAML module response
+            raise
         except Exception as e:
             # If decoding the response or mapping it to a user failed, then log the
             # error and tell the user that something went wrong.