summary refs log tree commit diff
path: root/synapse/handlers/cas.py
diff options
context:
space:
mode:
authorAurélien Grimpard <aurelien@grimpard.net>2024-05-14 14:55:32 +0200
committerGitHub <noreply@github.com>2024-05-14 13:55:32 +0100
commit7d82987b2765b6c203ba12941c844fb7242c6c83 (patch)
tree69d1fe25dfe6ad3d6e029ebf6cb5ff9d5ebf85d2 /synapse/handlers/cas.py
parentBump serde_json from 1.0.116 to 1.0.117 (#17182) (diff)
downloadsynapse-7d82987b2765b6c203ba12941c844fb7242c6c83.tar.xz
Allows CAS SSO flow to provide user IDs composed of numbers only (#17098)
Diffstat (limited to '')
-rw-r--r--synapse/handlers/cas.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/synapse/handlers/cas.py b/synapse/handlers/cas.py
index 153123ee83..cc3d641b7d 100644
--- a/synapse/handlers/cas.py
+++ b/synapse/handlers/cas.py
@@ -78,6 +78,8 @@ class CasHandler:
         self._cas_displayname_attribute = hs.config.cas.cas_displayname_attribute
         self._cas_required_attributes = hs.config.cas.cas_required_attributes
         self._cas_enable_registration = hs.config.cas.cas_enable_registration
+        self._cas_allow_numeric_ids = hs.config.cas.cas_allow_numeric_ids
+        self._cas_numeric_ids_prefix = hs.config.cas.cas_numeric_ids_prefix
 
         self._http_client = hs.get_proxied_http_client()
 
@@ -188,6 +190,9 @@ class CasHandler:
         for child in root[0]:
             if child.tag.endswith("user"):
                 user = child.text
+                # if numeric user IDs are allowed and username is numeric then we add the prefix so Synapse can handle it
+                if self._cas_allow_numeric_ids and user is not None and user.isdigit():
+                    user = f"{self._cas_numeric_ids_prefix}{user}"
             if child.tag.endswith("attributes"):
                 for attribute in child:
                     # ElementTree library expands the namespace in