From 041ba06e326c005d55a848acf9acacf2468d272a Mon Sep 17 00:00:00 2001 From: primetheus <865381+primetheus@users.noreply.github.com> Date: Sun, 17 Sep 2023 20:24:37 -0400 Subject: [PATCH 1/3] Fix LDAP_SERVER_PORT not being used makes use of the LDAP_SERVER_PORT variable --- githubapp/ldap.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/githubapp/ldap.py b/githubapp/ldap.py index 8af89f3..1e68dbc 100644 --- a/githubapp/ldap.py +++ b/githubapp/ldap.py @@ -15,7 +15,10 @@ class LDAPClient: def __init__(self): # Read settings from the config file and store them as constants self.LDAP_SERVER_HOST = os.environ["LDAP_SERVER_HOST"] - self.LDAP_SERVER_PORT = os.environ["LDAP_SERVER_PORT"] + if "LDAP_SERVER_PORT" in os.environ: + self.LDAP_SERVER_PORT = os.environ["LDAP_SERVER_PORT"] + else + self.LDAP_SERVER_PORT = 389 self.LDAP_BASE_DN = os.environ["LDAP_BASE_DN"] self.LDAP_USER_BASE_DN = os.environ["LDAP_USER_BASE_DN"] self.LDAP_USER_ATTRIBUTE = os.environ["LDAP_USER_ATTRIBUTE"] @@ -76,7 +79,7 @@ def __init__(self): self.srv = Server( host=self.LDAP_SERVER_HOST, - port=self.LDAP_SERVER_HOST, + port=self.LDAP_SERVER_PORT, use_ssl=self.USE_SSL, tls=self.tls, ) From ce94cf124fd4c8d0371d6a8f81f81ff6614b8402 Mon Sep 17 00:00:00 2001 From: primetheus <865381+primetheus@users.noreply.github.com> Date: Sun, 17 Sep 2023 20:27:33 -0400 Subject: [PATCH 2/3] add default LDAPS port --- githubapp/ldap.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/githubapp/ldap.py b/githubapp/ldap.py index 1e68dbc..07fea41 100644 --- a/githubapp/ldap.py +++ b/githubapp/ldap.py @@ -15,10 +15,6 @@ class LDAPClient: def __init__(self): # Read settings from the config file and store them as constants self.LDAP_SERVER_HOST = os.environ["LDAP_SERVER_HOST"] - if "LDAP_SERVER_PORT" in os.environ: - self.LDAP_SERVER_PORT = os.environ["LDAP_SERVER_PORT"] - else - self.LDAP_SERVER_PORT = 389 self.LDAP_BASE_DN = os.environ["LDAP_BASE_DN"] self.LDAP_USER_BASE_DN = os.environ["LDAP_USER_BASE_DN"] self.LDAP_USER_ATTRIBUTE = os.environ["LDAP_USER_ATTRIBUTE"] @@ -76,6 +72,13 @@ def __init__(self): ) else: self.tls = None + if "LDAP_SERVER_PORT" in os.environ: + self.LDAP_SERVER_PORT = os.environ["LDAP_SERVER_PORT"] + else + if self.LDAP_USE_SSL: + self.LDAP_SERVER_PORT = 636 + else: + self.LDAP_SERVER_PORT = 389 self.srv = Server( host=self.LDAP_SERVER_HOST, From af88129b185a1996ef830cd1207810f8b1ed3a81 Mon Sep 17 00:00:00 2001 From: Jared Murrell <865381+primetheus@users.noreply.github.com> Date: Sun, 17 Sep 2023 20:29:15 -0400 Subject: [PATCH 3/3] fixd if/else typo --- githubapp/ldap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/githubapp/ldap.py b/githubapp/ldap.py index 07fea41..7c8d33c 100644 --- a/githubapp/ldap.py +++ b/githubapp/ldap.py @@ -74,7 +74,7 @@ def __init__(self): self.tls = None if "LDAP_SERVER_PORT" in os.environ: self.LDAP_SERVER_PORT = os.environ["LDAP_SERVER_PORT"] - else + else: if self.LDAP_USE_SSL: self.LDAP_SERVER_PORT = 636 else: