diff options
| author | 2024-07-26 19:45:12 +0100 | |
|---|---|---|
| committer | 2024-07-26 19:45:12 +0100 | |
| commit | ffa16cb9575cb6c39b3c957d26a7e4dd0decc838 (patch) | |
| tree | 7c7d6987fb62318b1f00759f690515729f4a5edb /arthur/apis/directory/ldap.py | |
| parent | Add 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.py | 9 |
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) |