Skip to content

Commit 7dc4bcf

Browse files
authored
Skip LDAP users with no uid attribute (#82)
1 parent 9e7301f commit 7dc4bcf

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

CHANGES.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changelog
22
=========
33

4+
Version 0.5.4
5+
-------------
6+
7+
- Skip LDAP users that do not have the specified ``uid`` attribute set instead
8+
of failing with an error
9+
410
Version 0.5.3
511
-------------
612

flask_multipass/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from .identity import IdentityProvider
1414

1515

16-
__version__ = '0.5.3'
16+
__version__ = '0.5.4'
1717
__all__ = ('Multipass', 'AuthProvider', 'IdentityProvider', 'AuthInfo', 'IdentityInfo', 'Group', 'MultipassException',
1818
'AuthenticationFailed', 'IdentityRetrievalFailed', 'GroupRetrievalFailed', 'NoSuchUser',
1919
'InvalidCredentials')

flask_multipass/providers/ldap/providers.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,12 @@ def search_identities(self, criteria, exact=False):
202202
raise IdentityRetrievalFailed("Unable to generate search filter from criteria", provider=self)
203203
for _, user_data in self._search_users(search_filter):
204204
user_data = to_unicode(user_data)
205-
yield IdentityInfo(self, identifier=user_data[self.ldap_settings['uid']][0], **user_data)
205+
try:
206+
identifier = user_data[self.ldap_settings['uid']][0]
207+
except KeyError:
208+
# user does not have an identifier -> skip it
209+
continue
210+
yield IdentityInfo(self, identifier=identifier, **user_data)
206211

207212
def get_identity_groups(self, identifier):
208213
groups = set()

0 commit comments

Comments
 (0)