Skip to content

Commit

Permalink
Fix bug in users enumeration
Browse files Browse the repository at this point in the history
Wrong user could be retrieved
This refs #4
  • Loading branch information
laulaz committed Aug 8, 2023
1 parent 857e04d commit 6c39605
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Changelog
2.0.8 (unreleased)
------------------

- Fix bug in users enumeration : wrong user could be retrieved (#4)
[laulaz]

- Finally check certs on JWT call (except for test).
[bsuttor]

Expand Down
4 changes: 3 additions & 1 deletion src/pas/plugins/imio/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def enumerateUsers(
return at most one mapping per supplied ID ('id' and 'login'
may be sequences).
o If 'exact_match' is False, then 'id' and / or login may be
o If 'exact_match' is False, then 'id' and / or login and / or email may be
treated by the plugin as "contains" searches (more complicated
searches may be supported by some plugins using other keyword
arguments).
Expand Down Expand Up @@ -260,6 +260,8 @@ def enumerateUsers(
identity = self._useridentities_by_userid[search_id]
elif search_id in self._useridentities_by_login:
identity = self._useridentities_by_login[search_id]
else:
return []
if identity is not None:
identity_userid = identity.userid
if hasattr(identity, "login"):
Expand Down
5 changes: 5 additions & 0 deletions src/pas/plugins/imio/tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ def test_enumerate_users(self):
self.plugin.enumerateUsers(login="bond"),
[{"login": "jamesbond", "pluginid": "authentic", "id": "123456"}],
)
self.assertEqual(self.plugin.enumerateUsers(login="bond", exact_match=True), [])
self.assertEqual(
self.plugin.enumerateUsers(login="jamesbond", exact_match=True),
[{"login": "jamesbond", "pluginid": "authentic", "id": "123456"}],
)

def test_search_all_users(self):
count_users = 1
Expand Down

0 comments on commit 6c39605

Please sign in to comment.