Modify ldap validator to just check user existence

Remove auth user check from updating config app config

remove duplicate certs install script
This commit is contained in:
Sam Chow 2018-07-11 16:03:36 -04:00
parent bd54eacbad
commit 9024419896
7 changed files with 52 additions and 92 deletions

View file

@ -23,7 +23,8 @@ class LDAPValidator(BaseValidator):
# If there is a custom LDAP certificate, then reinstall the certificates for the container.
if config_provider.volume_file_exists(LDAP_CERT_FILENAME):
subprocess.check_call([os.path.join(init_scripts_location, 'certs_install.sh')])
subprocess.check_call([os.path.join(init_scripts_location, 'certs_install.sh')],
env={ 'QUAYCONF': config_provider.get_config_dir_path() })
# Note: raises ldap.INVALID_CREDENTIALS on failure
admin_dn = config.get('LDAP_ADMIN_DN')
@ -61,10 +62,10 @@ class LDAPValidator(BaseValidator):
users = LDAPUsers(ldap_uri, base_dn, admin_dn, admin_passwd, user_rdn, uid_attr, email_attr,
allow_tls_fallback, requires_email=requires_email)
username = user.username
(result, err_msg) = users.verify_credentials(username, user_password)
# Ensure at least one user exists to verify the connection is setup properly
(result, err_msg) = users.at_least_one_user_exists()
if not result:
msg = ('Verification of superuser %s failed: %s. \n\nThe user either does not exist ' +
msg = ('Verification that users exist failed: %s. \n\nNo users exist ' +
'in the remote authentication system ' +
'OR LDAP auth is misconfigured.') % (username, err_msg)
'OR LDAP auth is misconfigured.') % err_msg
raise ConfigValidationException(msg)