Skip to content

Commit

Permalink
use SCIM_PREFIX in homeserver.py
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk committed Sep 16, 2024
1 parent 76afb5d commit 06cd88f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
6 changes: 2 additions & 4 deletions synapse/app/homeserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
from synapse.rest.admin import AdminRestResource
from synapse.rest.health import HealthResource
from synapse.rest.key.v2 import KeyResource
from synapse.rest.scim import HAS_SCIM2, SCIMResource
from synapse.rest.scim import HAS_SCIM2, SCIM_PREFIX, SCIMResource
from synapse.rest.synapse.client import build_synapse_client_resource_tree
from synapse.rest.well_known import well_known_resource
from synapse.server import HomeServer
Expand Down Expand Up @@ -191,9 +191,7 @@ def _configure_named_resource(
)

if HAS_SCIM2:
resources["/_matrix/client/unstable/coop.yaal/scim/"] = SCIMResource(
self
)
resources[SCIM_PREFIX] = SCIMResource(self)

if self.config.email.can_verify_email:
from synapse.rest.synapse.client.password_reset import (
Expand Down
24 changes: 12 additions & 12 deletions synapse/rest/scim.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
if TYPE_CHECKING:
from synapse.server import HomeServer

SCIM_PREFIX = "_matrix/client/unstable/coop.yaal/scim"
SCIM_PREFIX = "/_matrix/client/unstable/coop.yaal/scim"

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -155,7 +155,7 @@ async def get_scim_user(self, user_id: str) -> "User":
resource_type="User",
created=creation_datetime,
last_modified=creation_datetime,
location=f"{self.config.server.public_baseurl}{SCIM_PREFIX}/Users/{user_id}",
location=f"{self.config.server.public_baseurl}{SCIM_PREFIX[1:]}/Users/{user_id}",
),
id=user_id,
external_id=user_id,
Expand Down Expand Up @@ -187,7 +187,7 @@ async def get_scim_user(self, user_id: str) -> "User":


class UserServlet(SCIMServlet):
PATTERNS = [re.compile(f"^/{SCIM_PREFIX}/Users/(?P<user_id>[^/]*)")]
PATTERNS = [re.compile(f"^{SCIM_PREFIX}/Users/(?P<user_id>[^/]*)")]

async def on_GET(
self, request: SynapseRequest, user_id: str
Expand Down Expand Up @@ -291,7 +291,7 @@ async def on_PUT(


class UserListServlet(SCIMServlet):
PATTERNS = [re.compile(f"^/{SCIM_PREFIX}/Users/?$")]
PATTERNS = [re.compile(f"^{SCIM_PREFIX}/Users/?$")]

async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
try:
Expand Down Expand Up @@ -378,15 +378,15 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:


class ServiceProviderConfigServlet(SCIMServlet):
PATTERNS = [re.compile(f"^/{SCIM_PREFIX}/ServiceProviderConfig$")]
PATTERNS = [re.compile(f"^{SCIM_PREFIX}/ServiceProviderConfig$")]

async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
spc = ServiceProviderConfig(
meta=Meta(
resource_type="ServiceProviderConfig",
location=(
self.config.server.public_baseurl
+ SCIM_PREFIX
+ SCIM_PREFIX[1:]
+ "/ServiceProviderConfig"
),
),
Expand Down Expand Up @@ -435,15 +435,15 @@ def __init__(self, hs: "HomeServer"):
resource_type=schema_name,
location=(
self.config.server.public_baseurl
+ SCIM_PREFIX
+ SCIM_PREFIX[1:]
+ "/Schemas/"
+ schema_id
),
)


class SchemaListServlet(BaseSchemaServlet):
PATTERNS = [re.compile(f"^/{SCIM_PREFIX}/Schemas$")]
PATTERNS = [re.compile(f"^{SCIM_PREFIX}/Schemas$")]

async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
"""Return the list of schemas provided by the synapse SCIM implementation."""
Expand All @@ -464,7 +464,7 @@ async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:


class SchemaServlet(BaseSchemaServlet):
PATTERNS = [re.compile(f"^/{SCIM_PREFIX}/Schemas/(?P<schema_id>[^/]*)$")]
PATTERNS = [re.compile(f"^{SCIM_PREFIX}/Schemas/(?P<schema_id>[^/]*)$")]

async def on_GET(
self, request: SynapseRequest, schema_id: str
Expand Down Expand Up @@ -494,15 +494,15 @@ def __init__(self, hs: "HomeServer"):
resource_type="ResourceType",
location=(
self.config.server.public_baseurl
+ SCIM_PREFIX
+ SCIM_PREFIX[1:]
+ "/ResourceTypes/User"
),
),
)


class ResourceTypeListServlet(BaseResourceTypeServlet):
PATTERNS = [re.compile(f"^/{SCIM_PREFIX}/ResourceTypes$")]
PATTERNS = [re.compile(f"^{SCIM_PREFIX}/ResourceTypes$")]

async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
req = self.parse_search_request(request)
Expand All @@ -523,7 +523,7 @@ async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:


class ResourceTypeServlet(BaseResourceTypeServlet):
PATTERNS = [re.compile(f"^/{SCIM_PREFIX}/ResourceTypes/(?P<resource_type>[^/]*)$")]
PATTERNS = [re.compile(f"^{SCIM_PREFIX}/ResourceTypes/(?P<resource_type>[^/]*)$")]

async def on_GET(
self, request: SynapseRequest, resource_type: str
Expand Down

0 comments on commit 06cd88f

Please sign in to comment.