@@ -571,18 +571,6 @@ def _ExtractShell(self, user_data):
571571 return default_shell
572572
573573
574- class UniqueSshkeyMapEntry (sshkey .SshkeyMapEntry ):
575- """SSH key map entry that uses composite key to allow multiple keys per user."""
576-
577- def Key (self ):
578- """Return a composite key that includes both username and SSH key.
579-
580- This allows multiple SSH keys for the same user to coexist in the map.
581- """
582- # Use a composite key of username + ssh key to make each entry unique
583- return f"{ self .name } :{ self .sshkey } "
584-
585-
586574class ScimSshkeyMapParser (ScimMapParser ):
587575 """Class for parsing SCIM Users into sshkey cache."""
588576
@@ -591,7 +579,7 @@ def __init__(self, source=None):
591579 super ().__init__ (source )
592580
593581 def _ReadEntry (self , user_data ):
594- """Return UniqueSshkeyMapEntry instances from a SCIM user resource."""
582+ """Return SshkeyMapEntry instances from a SCIM user resource."""
595583 entries = []
596584
597585 # Extract username using configurable path
@@ -616,16 +604,19 @@ def _ReadEntry(self, user_data):
616604 elif not isinstance (ssh_keys , list ):
617605 ssh_keys = []
618606
619- # Create an entry for each SSH key using our custom entry class
620- for ssh_key in ssh_keys :
621- if ssh_key and ssh_key .strip ():
622- map_entry = UniqueSshkeyMapEntry ()
623- map_entry .name = username
624- map_entry .sshkey = ssh_key .strip ()
625- entries .append (map_entry )
607+ # Filter out empty keys and strip whitespace
608+ valid_keys = [key .strip () for key in ssh_keys if key and key .strip ()]
626609
627- if ssh_keys :
628- self .log .debug ("Extracted %d SSH keys for user %s" , len (ssh_keys ), username )
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 )
629620
630621 return entries
631622
0 commit comments