Skip to content

Commit a09a421

Browse files
authored
Merge pull request #12 from coreweave/scim-posix-groupname
feat: Add custom groupname selection for SCIM
2 parents 0cf31a2 + ee4b68c commit a09a421

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

examples/nsscache-scim.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ scim_path_username = urn:example:params:scim:schemas:extension:User/userName
9292

9393
scim_path_username = urn:example:params:scim:schemas:extension:User/userName
9494
scim_path_gid = urn:example:params:scim:schemas:extension:User/groupId
95+
scim_path_groupname = CustomGroupName
9596

9697
##
9798
# Cache configuration - use local directory for testing

nss_cache/sources/scimsource.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -631,10 +631,8 @@ def __init__(self, source=None):
631631
def _ReadEntry(self, group_data):
632632
"""Return a GroupMapEntry from a SCIM group resource."""
633633

634-
# Use displayName or fallback to other name fields
635-
group_name = (group_data.get("displayName") or
636-
group_data.get("name") or
637-
group_data.get("id"))
634+
# Extract group name using configurable path
635+
group_name = self._ExtractGroupName(group_data)
638636

639637
if not group_name:
640638
self.log.warning("SCIM group missing name, skipping")
@@ -657,6 +655,21 @@ def _ReadEntry(self, group_data):
657655

658656
return map_entry
659657

658+
def _ExtractGroupName(self, group_data):
659+
"""Extract group name using configurable path."""
660+
groupname_path = self._GetMapConfig("scim_path_groupname", "")
661+
662+
# Try the configured path first
663+
if groupname_path:
664+
name = self._ExtractFromPath(group_data, groupname_path)
665+
if name:
666+
return name
667+
668+
# Fallback to standard SCIM name fields
669+
return (group_data.get("displayName") or
670+
group_data.get("name") or
671+
group_data.get("id"))
672+
660673
def _ExtractGroupGid(self, group_data):
661674
"""Extract GID from SCIM group data using configurable path."""
662675
gid_path = self._GetMapConfig("scim_path_gid", "")

nsscache.conf.5

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,13 @@ Path within SCIM user resources to extract the user ID (UID). Defaults to
423423
.B scim_path_gid
424424
Path within SCIM user/group resources to extract the group ID (GID).
425425

426+
.TP
427+
.B scim_path_groupname
428+
Path within SCIM group resources to extract the preferred group name. This can be
429+
used when the SCIM server provides a custom field for group names.
430+
If not specified or the path returns no value, nsscache will fall
431+
back to using displayName, name, or id from the SCIM group resource.
432+
426433
.TP
427434
.B scim_path_home_directory
428435
Path within SCIM user resources to extract the home directory. If not specified,

0 commit comments

Comments
 (0)