From 191398286052ddf1fe2650bb529fc39fd7b3fd25 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Thu, 21 Jan 2021 14:29:48 -0500 Subject: [PATCH 1/3] Do not require the CAS service URL. --- docs/sample_config.yaml | 4 ---- synapse/config/cas.py | 6 +----- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/docs/sample_config.yaml b/docs/sample_config.yaml index 87bfe2223731..c2ccd68f3aea 100644 --- a/docs/sample_config.yaml +++ b/docs/sample_config.yaml @@ -1878,10 +1878,6 @@ cas_config: # #server_url: "https://cas-server.com" - # The public URL of the homeserver. - # - #service_url: "https://homeserver.domain.com:8448" - # The attribute of the CAS response to use as the display name. # # If unset, no displayname will be set. diff --git a/synapse/config/cas.py b/synapse/config/cas.py index c7877b4095ac..a2cd3fff534e 100644 --- a/synapse/config/cas.py +++ b/synapse/config/cas.py @@ -30,7 +30,7 @@ def read_config(self, config, **kwargs): if self.cas_enabled: self.cas_server_url = cas_config["server_url"] - self.cas_service_url = cas_config["service_url"] + self.cas_service_url = cas_config.get("service_url") or self.public_baseurl self.cas_displayname_attribute = cas_config.get("displayname_attribute") self.cas_required_attributes = cas_config.get("required_attributes") or {} else: @@ -53,10 +53,6 @@ def generate_config_section(self, config_dir_path, server_name, **kwargs): # #server_url: "https://cas-server.com" - # The public URL of the homeserver. - # - #service_url: "https://homeserver.domain.com:8448" - # The attribute of the CAS response to use as the display name. # # If unset, no displayname will be set. From e6932debfe53c06533fb65ea110def43d718aa32 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Thu, 21 Jan 2021 14:31:28 -0500 Subject: [PATCH 2/3] Consistency with the OIDC handler. --- synapse/config/cas.py | 8 +++++++- synapse/config/oidc_config.py | 3 +-- synapse/handlers/cas_handler.py | 6 +----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/synapse/config/cas.py b/synapse/config/cas.py index a2cd3fff534e..b226890c2a20 100644 --- a/synapse/config/cas.py +++ b/synapse/config/cas.py @@ -30,7 +30,13 @@ def read_config(self, config, **kwargs): if self.cas_enabled: self.cas_server_url = cas_config["server_url"] - self.cas_service_url = cas_config.get("service_url") or self.public_baseurl + public_base_url = cas_config.get("service_url") or self.public_baseurl + if public_base_url[-1] != "/": + public_base_url += "/" + # TODO Update this to a _synapse URL. + self.cas_service_url = ( + public_base_url + "_matrix/client/r0/login/cas/ticket" + ) self.cas_displayname_attribute = cas_config.get("displayname_attribute") self.cas_required_attributes = cas_config.get("required_attributes") or {} else: diff --git a/synapse/config/oidc_config.py b/synapse/config/oidc_config.py index bfeceeed18f2..0162d7f7b092 100644 --- a/synapse/config/oidc_config.py +++ b/synapse/config/oidc_config.py @@ -54,8 +54,7 @@ def read_config(self, config, **kwargs): "Multiple OIDC providers have the idp_id %r." % idp_id ) - public_baseurl = self.public_baseurl - self.oidc_callback_url = public_baseurl + "_synapse/oidc/callback" + self.oidc_callback_url = self.public_baseurl + "_synapse/oidc/callback" @property def oidc_enabled(self) -> bool: diff --git a/synapse/handlers/cas_handler.py b/synapse/handlers/cas_handler.py index 0f342c607b27..21b6bc4992a8 100644 --- a/synapse/handlers/cas_handler.py +++ b/synapse/handlers/cas_handler.py @@ -99,11 +99,7 @@ def _build_service_param(self, args: Dict[str, str]) -> str: Returns: The URL to use as a "service" parameter. """ - return "%s%s?%s" % ( - self._cas_service_url, - "/_matrix/client/r0/login/cas/ticket", - urllib.parse.urlencode(args), - ) + return "%s?%s" % (self._cas_service_url, urllib.parse.urlencode(args),) async def _validate_ticket( self, ticket: str, service_args: Dict[str, str] From 237469ec58b69815121d759ffdad710c64dd2b60 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Thu, 21 Jan 2021 14:37:54 -0500 Subject: [PATCH 3/3] Newsfragment. --- changelog.d/9199.removal | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/9199.removal diff --git a/changelog.d/9199.removal b/changelog.d/9199.removal new file mode 100644 index 000000000000..fbd2916cbf54 --- /dev/null +++ b/changelog.d/9199.removal @@ -0,0 +1 @@ +The `service_url` parameter in `cas_config` is deprecated in favor of `public_baseurl`.