This commit is contained in:
2026-10-29 14:49:44 -04:00
parent 920a608fba
commit 9eac45a7f9
6 changed files with 120 additions and 15 deletions
+26
View File
@@ -35,3 +35,29 @@ def configured_groups(tiers, service_groups):
return {tier["group_dn"] for tier in tiers.values()} | {
dn for groups in service_groups.values() for dn in groups
}
def service_names(level, service_groups):
"""Public labels from the same exact-level mapping used by reconciliation."""
labels = {
"dex users": "Dex · single sign-on",
"discourse users": "Discourse · community forums",
"gitea users": "Gitea · Git hosting",
"matrix users": "Matrix · community chat",
"mastodon users": "Mastodon · social networking",
"peertube users": "PeerTube · video sharing",
}
names = []
for dn in service_groups.get(str(level), []):
# Show only a group's common name, never its directory hierarchy.
common_name = next((value for attribute, value, _separator in parse_dn(dn) if attribute.casefold() == "cn"), "")
if not common_name:
name = "Additional community service"
else:
# LDAP DN values escape reserved characters and UTF-8 bytes.
raw = re.sub(r"\\([,=+<>#;\"\\ ])", r"\1", common_name)
raw = re.sub(r"(?:\\[0-9a-fA-F]{2})+", lambda match: bytes.fromhex(match.group().replace("\\", "")).decode("utf-8", errors="replace"), raw)
name = labels.get(raw.casefold(), re.sub(r"\s+users$", "", raw, flags=re.IGNORECASE))
if name not in names:
names.append(name)
return names