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 d1c3438 commit fdc3f65
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -10,6 +10,9 @@ This document describes changes between each past release.
- Set default value for ``multiauth.policy.ldap.use`` (fixes #3)
- Add the plugin version in the capability.

**Bug fixes**

- 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 fdc3f65

Please sign in to comment.