moved more saml imports behind checks
(tried everything with pysaml2 uninstalled so should now work!)
This commit is contained in:
@@ -40,7 +40,6 @@ from synapse.crypto import context_factory
|
||||
from synapse.events.presence_router import load_legacy_presence_router
|
||||
from synapse.events.spamcheck import load_legacy_spam_checkers
|
||||
from synapse.events.third_party_rules import load_legacy_third_party_event_rules
|
||||
from synapse.handlers.saml import load_default_or_legacy_saml2_mapping_provider
|
||||
from synapse.logging.context import PreserveLoggingContext
|
||||
from synapse.metrics.background_process_metrics import wrap_as_background_process
|
||||
from synapse.metrics.jemalloc import setup_jemalloc_stats
|
||||
@@ -380,6 +379,8 @@ async def start(hs: "HomeServer"):
|
||||
hs.config.saml2.saml2_enabled
|
||||
and not hs.get_saml2_user_mapping_provider().module_has_registered
|
||||
):
|
||||
from synapse.handlers.saml import load_default_or_legacy_saml2_mapping_provider
|
||||
|
||||
load_default_or_legacy_saml2_mapping_provider(hs)
|
||||
|
||||
# If we've configured an expiry time for caches, start the background job now.
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -18,7 +18,6 @@ from unittest.mock import Mock
|
||||
import attr
|
||||
|
||||
from synapse.api.errors import RedirectException
|
||||
from synapse.handlers.saml import load_default_or_legacy_saml2_mapping_provider
|
||||
|
||||
from tests.test_utils import simple_async_mock
|
||||
from tests.unittest import HomeserverTestCase, override_config
|
||||
@@ -28,6 +27,8 @@ try:
|
||||
import saml2.config
|
||||
from saml2.sigver import SigverError
|
||||
|
||||
from synapse.handlers.saml import load_default_or_legacy_saml2_mapping_provider
|
||||
|
||||
has_saml2 = True
|
||||
|
||||
# pysaml2 can be installed and imported, but might not be able to find xmlsec1.
|
||||
|
||||
Reference in New Issue
Block a user