Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/uds/core/util/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, []))]
Expand Down
18 changes: 18 additions & 0 deletions tests/core/util/test_auth_regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)
Loading