Skip to content

Commit d771119

Browse files
committed
fix: Allow multiple sshkeys to be added to map in scimsource
1 parent e878f68 commit d771119

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

nss_cache/sources/scimsource.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -604,16 +604,19 @@ def _ReadEntry(self, user_data):
604604
elif not isinstance(ssh_keys, list):
605605
ssh_keys = []
606606

607-
# Create an entry for each SSH key
608-
for ssh_key in ssh_keys:
609-
if ssh_key and ssh_key.strip():
610-
map_entry = sshkey.SshkeyMapEntry()
611-
map_entry.name = username
612-
map_entry.sshkey = ssh_key.strip()
613-
entries.append(map_entry)
614-
615-
if ssh_keys:
616-
self.log.debug("Extracted %d SSH keys for user %s", len(ssh_keys), username)
607+
# Filter out empty keys and strip whitespace
608+
valid_keys = [key.strip() for key in ssh_keys if key and key.strip()]
609+
610+
# Create a single entry with all SSH keys as a list
611+
map_entry = sshkey.SshkeyMapEntry()
612+
map_entry.name = username
613+
if valid_keys:
614+
map_entry.sshkey = valid_keys
615+
else:
616+
# Always create an entry, even if no keys
617+
map_entry.sshkey = ""
618+
self.log.debug("Extracted %d SSH keys for user %s", len(valid_keys), username)
619+
entries.append(map_entry)
617620

618621
return entries
619622

0 commit comments

Comments
 (0)