summary refs log tree commit diff
path: root/synapse/config
diff options
context:
space:
mode:
authorAurélien Grimpard <aurelien@grimpard.net>2023-08-24 22:11:23 +0200
committerGitHub <noreply@github.com>2023-08-24 16:11:23 -0400
commitaeeca2a62ebfb601efa7930acae0897c8d3e43df (patch)
treeed4401902543aebd0ac8090472fe01d4a68e993f /synapse/config
parentBump anyhow from 1.0.72 to 1.0.75 (#16141) (diff)
downloadsynapse-aeeca2a62ebfb601efa7930acae0897c8d3e43df.tar.xz
Add configuration setting for CAS protocol version (#15816)
Diffstat (limited to 'synapse/config')
-rw-r--r--synapse/config/cas.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/synapse/config/cas.py b/synapse/config/cas.py
index c4e63e7411..6e2d9addbf 100644
--- a/synapse/config/cas.py
+++ b/synapse/config/cas.py
@@ -18,7 +18,7 @@ from typing import Any, List
 from synapse.config.sso import SsoAttributeRequirement
 from synapse.types import JsonDict
 
-from ._base import Config
+from ._base import Config, ConfigError
 from ._util import validate_config
 
 
@@ -41,6 +41,16 @@ class CasConfig(Config):
             public_baseurl = self.root.server.public_baseurl
             self.cas_service_url = public_baseurl + "_matrix/client/r0/login/cas/ticket"
 
+            self.cas_protocol_version = cas_config.get("protocol_version")
+            if (
+                self.cas_protocol_version is not None
+                and self.cas_protocol_version not in [1, 2, 3]
+            ):
+                raise ConfigError(
+                    "Unsupported CAS protocol version %s (only versions 1, 2, 3 are supported)"
+                    % (self.cas_protocol_version,),
+                    ("cas_config", "protocol_version"),
+                )
             self.cas_displayname_attribute = cas_config.get("displayname_attribute")
             required_attributes = cas_config.get("required_attributes") or {}
             self.cas_required_attributes = _parsed_required_attributes_def(
@@ -54,6 +64,7 @@ class CasConfig(Config):
         else:
             self.cas_server_url = None
             self.cas_service_url = None
+            self.cas_protocol_version = None
             self.cas_displayname_attribute = None
             self.cas_required_attributes = []