From 862d820d44a45e9af20e4ab55054aa8604efccb4 Mon Sep 17 00:00:00 2001 From: Azrenbeth <7782548+Azrenbeth@users.noreply.github.com> Date: Wed, 25 Aug 2021 11:49:21 +0100 Subject: moved more saml imports behind checks (tried everything with pysaml2 uninstalled so should now work!) --- synapse/module_api/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'synapse/module_api/__init__.py') diff --git a/synapse/module_api/__init__.py b/synapse/module_api/__init__.py index f337a0f65b..49dfeb78ed 100644 --- a/synapse/module_api/__init__.py +++ b/synapse/module_api/__init__.py @@ -117,7 +117,8 @@ class ModuleApi: self._account_validity_handler = hs.get_account_validity_handler() self._third_party_event_rules = hs.get_third_party_event_rules() self._presence_router = hs.get_presence_router() - self._saml2_user_mapping_provider = hs.get_saml2_user_mapping_provider() + if hs.config.saml2.saml2_enabled: + self._saml2_user_mapping_provider = hs.get_saml2_user_mapping_provider() ################################################################################# # The following methods should only be called during the module's initialisation. @@ -145,6 +146,10 @@ class ModuleApi: @property def register_saml2_user_mapping_provider_callbacks(self): """Registers callbacks for presence router capabilities.""" + if not self._hs.config.saml2.saml2_enabled: + raise RuntimeError( + "Saml2 is not enabled, so cannot register saml2 usr mapping provider callbacks" + ) return ( self._saml2_user_mapping_provider.register_saml2_user_mapping_provider_callbacks ) -- cgit 1.5.1