Add check_group_lookup_args and service_metadata to auth providers
This commit is contained in:
parent
1cfc4a8341
commit
ecfac81721
5 changed files with 71 additions and 0 deletions
|
@ -259,6 +259,26 @@ class LDAPUsers(FederatedUsers):
|
|||
|
||||
return self._build_user_information(found_response)
|
||||
|
||||
def service_metadata(self):
|
||||
return {
|
||||
'base_dn': self._base_dn,
|
||||
}
|
||||
|
||||
def check_group_lookup_args(self, group_lookup_args, disable_pagination=False):
|
||||
if not group_lookup_args.get('group_dn'):
|
||||
return (False, 'Missing group_dn')
|
||||
|
||||
(it, err) = self.iterate_group_members(group_lookup_args, page_size=1,
|
||||
disable_pagination=disable_pagination)
|
||||
if err is not None:
|
||||
return (False, err)
|
||||
|
||||
results = list(it)
|
||||
if not results:
|
||||
return (False, 'Group does not exist or is empty')
|
||||
|
||||
return (True, None)
|
||||
|
||||
def iterate_group_members(self, group_lookup_args, page_size=None, disable_pagination=False):
|
||||
try:
|
||||
with self._ldap.get_connection():
|
||||
|
|
Reference in a new issue