Skip to content

Commit

Permalink
Returns None and log exception if LDAP backend cannot be reached (fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem committed Nov 2, 2016
1 parent bb7d6c2 commit 0284bd0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Expand Up @@ -13,6 +13,7 @@ This document describes changes between each past release.
**Bug fixes**

- Fix heartbeat when server is unreachable (fixes #8)
- Returns None and log exception if LDAP backend cannot be reached (fixes #9)

0.1.0 (2016-06-27)
------------------
Expand Down
3 changes: 3 additions & 0 deletions kinto_ldap/authentication.py
Expand Up @@ -2,6 +2,7 @@

from kinto.core import utils
from ldap import INVALID_CREDENTIALS
from ldappool import BackendError
from pyramid.authentication import BasicAuthAuthenticationPolicy

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -33,6 +34,8 @@ def user_checker(username, password, request):
with cm.connection(ldap_fqn.format(mail=username), password):
cache.set(cache_key, "1", ttl=cache_ttl)
return []
except BackendError:
logger.exception("LDAP error")
except INVALID_CREDENTIALS:
cache.set(cache_key, "0", ttl=cache_ttl)

Expand Down

0 comments on commit 0284bd0

Please sign in to comment.