mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #51010 from amendlik/ldap-groups
Allow unauthenticated bind for listing LDAP groups
This commit is contained in:
commit
563d4875b8
2 changed files with 11 additions and 4 deletions
|
@ -323,7 +323,14 @@ def groups(username, **kwargs):
|
|||
|
||||
'''
|
||||
group_list = []
|
||||
bind = auth(username, kwargs.get('password', None))
|
||||
|
||||
# If bind credentials are configured, use them instead of user's
|
||||
if _config('binddn', mandatory=False) and _config('bindpw', mandatory=False):
|
||||
bind = _bind_for_search(anonymous=_config('anonymous', mandatory=False))
|
||||
else:
|
||||
bind = _bind(username, kwargs.get('password', ''),
|
||||
anonymous=_config('auth_by_group_membership_only', mandatory=False)
|
||||
and _config('anonymous', mandatory=False))
|
||||
|
||||
if bind:
|
||||
log.debug('ldap bind to determine group membership succeeded!')
|
||||
|
|
|
@ -67,7 +67,7 @@ class LDAPAuthTestCase(TestCase):
|
|||
'''
|
||||
self.opts['auth.ldap.freeipa'] = True
|
||||
with patch.dict(salt.auth.ldap.__opts__, self.opts):
|
||||
with patch('salt.auth.ldap.auth', return_value=Bind):
|
||||
with patch('salt.auth.ldap._bind', return_value=Bind):
|
||||
self.assertIn('saltusers', salt.auth.ldap.groups('saltuser', password='password'))
|
||||
|
||||
def test_groups(self):
|
||||
|
@ -75,7 +75,7 @@ class LDAPAuthTestCase(TestCase):
|
|||
test groups in ldap
|
||||
'''
|
||||
with patch.dict(salt.auth.ldap.__opts__, self.opts):
|
||||
with patch('salt.auth.ldap.auth', return_value=Bind):
|
||||
with patch('salt.auth.ldap._bind', return_value=Bind):
|
||||
self.assertIn('saltusers', salt.auth.ldap.groups('saltuser', password='password'))
|
||||
|
||||
def test_groups_activedirectory(self):
|
||||
|
@ -84,7 +84,7 @@ class LDAPAuthTestCase(TestCase):
|
|||
'''
|
||||
self.opts['auth.ldap.activedirectory'] = True
|
||||
with patch.dict(salt.auth.ldap.__opts__, self.opts):
|
||||
with patch('salt.auth.ldap.auth', return_value=Bind):
|
||||
with patch('salt.auth.ldap._bind', return_value=Bind):
|
||||
self.assertIn('saltusers', salt.auth.ldap.groups('saltuser', password='password'))
|
||||
|
||||
def test_auth_nopass(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue