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

Commit

Permalink
Do not require the CAS service URL setting (use public_baseurl instea…
Browse files Browse the repository at this point in the history
…d). (#9199)

The current configuration is handled for backwards compatibility,
but is considered deprecated.
  • Loading branch information
clokep authored Jan 26, 2021
1 parent dd8da8c commit 26837d5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 16 deletions.
1 change: 1 addition & 0 deletions changelog.d/9199.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The `service_url` parameter in `cas_config` is deprecated in favor of `public_baseurl`.
4 changes: 0 additions & 4 deletions docs/sample_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 7 additions & 5 deletions synapse/config/cas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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["service_url"]
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:
Expand All @@ -53,10 +59,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.
Expand Down
3 changes: 1 addition & 2 deletions synapse/config/oidc_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 1 addition & 5 deletions synapse/handlers/cas_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 26837d5

Please sign in to comment.