diff --git a/src/uds/core/util/auth.py b/src/uds/core/util/auth.py index cb086bd22..c5296b0dd 100644 --- a/src/uds/core/util/auth.py +++ b/src/uds/core/util/auth.py @@ -147,7 +147,7 @@ def _get_attr(attr_name: str) -> list[str]: # Prepend the value after ** to attribute value before ** attr, prependable = attr_name.split("**") val = [prependable + a for a in ensure.as_list(attributes.get(attr, []))] - elif ":" in attr_name: + elif ":" in attr_name and attr_name not in attributes: # "prefix:attr" — look up attr, prepend prefix to each value (e.g. alumno:alum + "S" -> "alumnoS") prefix, attr = attr_name.split(":", 1) val = [prefix + a for a in ensure.as_list(attributes.get(attr, []))] diff --git a/tests/core/util/test_auth_regex.py b/tests/core/util/test_auth_regex.py index a033f9c2a..459c92d96 100644 --- a/tests/core/util/test_auth_regex.py +++ b/tests/core/util/test_auth_regex.py @@ -57,3 +57,21 @@ def test_get_attributes_regex_field_colon(self) -> None: from uds.core.util.auth import get_attributes_regex_field self.assertEqual(get_attributes_regex_field("alumno:alumno\npas:pas"), {"alumno", "pas"}) + + def test_attribute_name_with_colon_is_used_verbatim(self) -> None: + from uds.core.util.auth import process_regex_field + + attributes = { + "urn:oid:1.3.6.1.4.1.5923.1.5.1.1": ["staff"], + "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress": ["user@example.com"], + } + self.assertEqual( + process_regex_field("urn:oid:1.3.6.1.4.1.5923.1.5.1.1", attributes), + ["staff"], + ) + self.assertEqual( + process_regex_field( + "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress=(.*)@", attributes + ), + ["user"], + )