Skip to content

Commit 1f1eda8

Browse files
author
Kota Tsuyuzaki
committed
Add connect_timeout option for LDAP connection
That option will enable the LDAP client to give up to connect to the server in the specific seconds.
1 parent 99dad8c commit 1f1eda8

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

ldapauthenticator/ldapauthenticator.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,13 @@ def _server_port_default(self):
236236
primary LDAP server is unavailable.
237237
""",
238238
)
239+
connect_timeout = Int(
240+
config=True,
241+
default=15,
242+
help="""
243+
LDAP client connect timeout (seconds)
244+
""",
245+
)
239246

240247
def resolve_username(self, username_supplied_by_user):
241248
search_dn = self.lookup_dn_search_user
@@ -337,7 +344,10 @@ def get_connection(self, userdn, password):
337344

338345
def _get_real_connection(self, userdn, password, server_address, server_port):
339346
server = ldap3.Server(
340-
server_address, port=server_port, use_ssl=self.use_ssl
347+
server_address,
348+
port=server_port,
349+
use_ssl=self.use_ssl,
350+
connect_timeout=self.connect_timeout,
341351
)
342352
auto_bind = (
343353
ldap3.AUTO_BIND_NO_TLS if self.use_ssl else ldap3.AUTO_BIND_TLS_BEFORE_BIND

0 commit comments

Comments
 (0)