Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Move sso init into build_synapse_client_resource_tree
Browse files Browse the repository at this point in the history
... so that we don't have to do it for each worker
  • Loading branch information
richvdh committed Feb 1, 2021
1 parent a83decf commit 3fb8c08
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
10 changes: 0 additions & 10 deletions synapse/app/homeserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,6 @@ def _configure_named_resource(self, name, compress=False):
}
)

if self.get_config().oidc_enabled:
from synapse.rest.oidc import OIDCResource

resources["/_synapse/oidc"] = OIDCResource(self)

if self.get_config().saml2_enabled:
from synapse.rest.saml2 import SAML2Resource

resources["/_matrix/saml2"] = SAML2Resource(self)

if self.get_config().threepid_behaviour_email == ThreepidBehaviour.LOCAL:
from synapse.rest.synapse.client.password_reset import (
PasswordResetSubmitTokenResource,
Expand Down
12 changes: 12 additions & 0 deletions synapse/rest/synapse/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ def build_synapse_client_resource_tree(hs: "HomeServer") -> Mapping[str, Resourc
"/_synapse/client/sso_register": SsoRegisterResource(hs),
}

# provider-specific SSO bits. Only load these if they are enabled, since they
# rely on optional dependencies.
if hs.config.oidc_enabled:
from synapse.rest.oidc import OIDCResource

resources["/_synapse/oidc"] = OIDCResource(hs)

if hs.config.saml2_enabled:
from synapse.rest.saml2 import SAML2Resource

resources["/_matrix/saml2"] = SAML2Resource(hs)

return resources


Expand Down
6 changes: 0 additions & 6 deletions tests/rest/client/v1/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,11 +422,8 @@ def default_config(self) -> Dict[str, Any]:
return config

def create_resource_dict(self) -> Dict[str, Resource]:
from synapse.rest.oidc import OIDCResource

d = super().create_resource_dict()
d.update(build_synapse_client_resource_tree(self.hs))
d["/_synapse/oidc"] = OIDCResource(self.hs)
return d

def test_get_login_flows(self):
Expand Down Expand Up @@ -1210,11 +1207,8 @@ def default_config(self):
return config

def create_resource_dict(self) -> Dict[str, Resource]:
from synapse.rest.oidc import OIDCResource

d = super().create_resource_dict()
d.update(build_synapse_client_resource_tree(self.hs))
d["/_synapse/oidc"] = OIDCResource(self.hs)
return d

def test_username_picker(self):
Expand Down
6 changes: 2 additions & 4 deletions tests/rest/client/v2_alpha/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from synapse.handlers.ui_auth.checkers import UserInteractiveAuthChecker
from synapse.rest.client.v1 import login
from synapse.rest.client.v2_alpha import auth, devices, register
from synapse.rest.oidc import OIDCResource
from synapse.rest.synapse.client import build_synapse_client_resource_tree
from synapse.types import JsonDict, UserID

from tests import unittest
Expand Down Expand Up @@ -173,9 +173,7 @@ def default_config(self):

def create_resource_dict(self):
resource_dict = super().create_resource_dict()
if HAS_OIDC:
# mount the OIDC resource at /_synapse/oidc
resource_dict["/_synapse/oidc"] = OIDCResource(self.hs)
resource_dict.update(build_synapse_client_resource_tree(self.hs))
return resource_dict

def prepare(self, reactor, clock, hs):
Expand Down

0 comments on commit 3fb8c08

Please sign in to comment.