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

Backout changes for automatically calculating the public baseurl #9313

Merged
merged 9 commits into from
Feb 11, 2021
Prev Previous commit
Next Next commit
Add a config check for the CAS service_url.
  • Loading branch information
clokep committed Feb 8, 2021
commit 4efab71ad1cf8c2a1131e3cd4a5610b90e85800c
23 changes: 16 additions & 7 deletions synapse/config/cas.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from ._base import Config
from ._base import Config, ConfigError


class CasConfig(Config):
Expand All @@ -30,13 +30,22 @@ def read_config(self, config, **kwargs):

if self.cas_enabled:
self.cas_server_url = cas_config["server_url"]
public_base_url = cas_config.get("service_url") or self.public_baseurl
if public_base_url[-1] != "/":
public_base_url += "/"

# The public baseurl is required because it is used by the redirect
# template.
public_baseurl = self.public_baseurl
if not public_baseurl:
raise ConfigError("cas_config requires a public_baseurl to be set")

# If the service_url is given, use it for backwards compatibility.
# Otherwise, use the public_baseurl.
if cas_config.get("service_url"):
public_baseurl = cas_config["service_url"]
if public_baseurl[-1] != "/":
public_baseurl += "/"

# TODO Update this to a _synapse URL.
self.cas_service_url = (
public_base_url + "_matrix/client/r0/login/cas/ticket"
)
self.cas_service_url = public_baseurl + "_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 Down
4 changes: 3 additions & 1 deletion tests/rest/client/v1/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,10 +672,12 @@ def make_homeserver(self, reactor, clock):
self.redirect_path = "_synapse/client/login/sso/redirect/confirm"

config = self.default_config()
config["public_baseurl"] = (
config.get("public_baseurl") or "https://matrix.goodserver.com:8448"
)
config["cas_config"] = {
"enabled": True,
"server_url": CAS_SERVER,
"service_url": "https://matrix.goodserver.com:8448",
}

cas_user_id = "username"
Expand Down