Skip to content

Commit

Permalink
Add connect_timeout option for LDAP connection
Browse files Browse the repository at this point in the history
That option will enable the LDAP client to give up
to connect to the server in the specific seconds.
  • Loading branch information
Kota Tsuyuzaki committed Apr 20, 2021
1 parent 881faf2 commit a4709e8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions ldapauthenticator/ldapauthenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,13 @@ def _server_port_default(self):
help="""
Comma separated address:port of the LDAP server which can be tried to contact when
primary LDAP server is unavailable.
""",
)
connect_timeout = Int(
config=True,
default=15,
help="""
LDAP client connect timeout (seconds)
""",
)

Expand Down Expand Up @@ -338,7 +344,10 @@ def get_connection(self, userdn, password):

def _get_real_connection(self, userdn, password, server_address, server_port):
server = ldap3.Server(
server_address, port=server_port, use_ssl=self.use_ssl
server_address,
port=server_port,
use_ssl=self.use_ssl,
connect_timeout=self.connect_timeout,
)
auto_bind = (
ldap3.AUTO_BIND_NO_TLS if self.use_ssl else ldap3.AUTO_BIND_TLS_BEFORE_BIND
Expand Down

0 comments on commit a4709e8

Please sign in to comment.