aboutsummaryrefslogtreecommitdiffstats
path: root/arthur/apis/directory/ldap.py
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2024-07-26 19:45:12 +0100
committerGravatar Joe Banks <[email protected]>2024-07-26 19:45:12 +0100
commitffa16cb9575cb6c39b3c957d26a7e4dd0decc838 (patch)
tree7c7d6987fb62318b1f00759f690515729f4a5edb /arthur/apis/directory/ldap.py
parentAdd new flag for enabling LDAP functionality (diff)
Expose a BONSAI_AVAILABLE flag from modules that depend on Bonsai
Diffstat (limited to 'arthur/apis/directory/ldap.py')
-rw-r--r--arthur/apis/directory/ldap.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/arthur/apis/directory/ldap.py b/arthur/apis/directory/ldap.py
index a4941af..c919f55 100644
--- a/arthur/apis/directory/ldap.py
+++ b/arthur/apis/directory/ldap.py
@@ -3,7 +3,12 @@
from dataclasses import dataclass
from functools import cache
-from bonsai import LDAPClient, LDAPDN, LDAPSearchScope
+try:
+ from bonsai import LDAPClient, LDAPDN, LDAPSearchScope
+
+ BONSAI_AVAILABLE = True
+except ImportError:
+ BONSAI_AVAILABLE = False
from arthur.config import CONFIG
from arthur.constants import LDAP_ROLE_MAPPING
@@ -32,7 +37,7 @@ def get_cn(dn: str) -> str:
@cache
-def create_client() -> LDAPClient:
+def create_client() -> "LDAPClient":
"""Create an LDAP client with the configured settings."""
client = LDAPClient(str(CONFIG.ldap_host), tls=True)