Skip to content

Commit 1ed6450

Browse files
authored
Merge branch 'master' into feature/tls-settings
2 parents af008a8 + 8285859 commit 1ed6450

File tree

6 files changed

+31
-3
lines changed

6 files changed

+31
-3
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
django-python3-ldap changelog
22
=============================
33

4+
0.15.7
5+
------
6+
7+
- Added ``LDAP_AUTH_POOL_ACTIVE`` setting (@borislaviv).
8+
9+
410
0.15.6
511
------
612

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ Available settings
106106
# Unspecified keyword arguments to apply to the connection in the underlying `ldap3` library.
107107
LDAP_AUTH_CONNECT_ARGS = {}
108108
109+
# Set connection pool `active` parameter on the underlying `ldap3` library.
110+
LDAP_AUTH_POOL_ACTIVE = True
109111
110112
Microsoft Active Directory support
111113
----------------------------------

django_python3_ldap/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
Django LDAP user authentication backend for Python 3.
33
"""
44

5-
6-
__version__ = (0, 15, 6)
5+
__version__ = (0, 15, 7)

django_python3_ldap/conf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,5 +156,10 @@ def __init__(self, settings):
156156
default=None
157157
)
158158

159+
LDAP_AUTH_POOL_ACTIVE = LazySetting(
160+
name="LDAP_AUTH_POOL_ACTIVE",
161+
default=True
162+
)
163+
159164

160165
settings = LazySettings(settings)

django_python3_ldap/ldap.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,11 @@ def connection(**kwargs):
162162
password = kwargs.pop("password")
163163
username = format_username(kwargs)
164164
# Build server pool
165-
server_pool = ldap3.ServerPool(None, ldap3.RANDOM, active=True, exhaust=5)
165+
server_pool = ldap3.ServerPool(
166+
None, ldap3.RANDOM,
167+
active=settings.LDAP_AUTH_POOL_ACTIVE,
168+
exhaust=5
169+
)
166170
auth_url = settings.LDAP_AUTH_URL
167171
if not isinstance(auth_url, list):
168172
auth_url = [auth_url]

django_python3_ldap/tests.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,18 @@ def testAuthenticateWithFailedRebind(self):
149149
)
150150
self.assertIs(user, None)
151151

152+
def testAuthenticateWithLimitedRetries(self):
153+
# simulate offline server
154+
with self.settings(
155+
LDAP_AUTH_URL=["ldap://example.com:389"],
156+
LDAP_AUTH_POOL_ACTIVE=1,
157+
):
158+
user = authenticate(
159+
username=settings.LDAP_AUTH_TEST_USER_USERNAME,
160+
password=settings.LDAP_AUTH_TEST_USER_PASSWORD,
161+
)
162+
self.assertEqual(user, None)
163+
152164
# User synchronisation.
153165

154166
def testSyncUsersCreatesUsers(self):

0 commit comments

Comments
 (0)