Skip to content

Commit

Permalink
Skip LDAP users with no uid attribute (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThiefMaster authored Mar 30, 2024
1 parent 9e7301f commit 7dc4bcf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

Version 0.5.4
-------------

- Skip LDAP users that do not have the specified ``uid`` attribute set instead
of failing with an error

Version 0.5.3
-------------

Expand Down
2 changes: 1 addition & 1 deletion flask_multipass/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from .identity import IdentityProvider


__version__ = '0.5.3'
__version__ = '0.5.4'
__all__ = ('Multipass', 'AuthProvider', 'IdentityProvider', 'AuthInfo', 'IdentityInfo', 'Group', 'MultipassException',
'AuthenticationFailed', 'IdentityRetrievalFailed', 'GroupRetrievalFailed', 'NoSuchUser',
'InvalidCredentials')
7 changes: 6 additions & 1 deletion flask_multipass/providers/ldap/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,12 @@ def search_identities(self, criteria, exact=False):
raise IdentityRetrievalFailed("Unable to generate search filter from criteria", provider=self)
for _, user_data in self._search_users(search_filter):
user_data = to_unicode(user_data)
yield IdentityInfo(self, identifier=user_data[self.ldap_settings['uid']][0], **user_data)
try:
identifier = user_data[self.ldap_settings['uid']][0]
except KeyError:
# user does not have an identifier -> skip it
continue
yield IdentityInfo(self, identifier=identifier, **user_data)

def get_identity_groups(self, identifier):
groups = set()
Expand Down

0 comments on commit 7dc4bcf

Please sign in to comment.