From d1eb33bca0a5f9725f85e5a195063c5b05e7b6f2 Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Fri, 7 Apr 2017 16:44:46 -0400 Subject: [PATCH] Be more restrictive in catching LDAP exceptions. django-auth-ldap can throw exceptions, like TypeError if it's misconfigured. If we encounter an exception attempting to log into an LDAP server, log it and move on (otherwise, an uncaught exception will cause local login to fail, too). see: #5933 --- awx/sso/backends.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/awx/sso/backends.py b/awx/sso/backends.py index 9a37ea8bf1..273778b371 100644 --- a/awx/sso/backends.py +++ b/awx/sso/backends.py @@ -12,7 +12,6 @@ from django.dispatch import receiver from django.contrib.auth.models import User from django.conf import settings as django_settings from django.core.signals import setting_changed -from django.core.exceptions import ImproperlyConfigured # django-auth-ldap from django_auth_ldap.backend import LDAPSettings as BaseLDAPSettings @@ -90,8 +89,8 @@ class LDAPBackend(BaseLDAPBackend): return None try: return super(LDAPBackend, self).authenticate(username, password) - except ImproperlyConfigured: - logger.error("Unable to authenticate, LDAP is improperly configured") + except Exception: + logger.exception("Encountered an error authenticating to LDAP") return None def get_user(self, user_id):