diff options
| -rw-r--r-- | arthur/apis/directory/freeipa.py | 8 | ||||
| -rw-r--r-- | arthur/apis/directory/ldap.py | 9 | 
2 files changed, 14 insertions, 3 deletions
diff --git a/arthur/apis/directory/freeipa.py b/arthur/apis/directory/freeipa.py index c534a6b..9da9d76 100644 --- a/arthur/apis/directory/freeipa.py +++ b/arthur/apis/directory/freeipa.py @@ -3,7 +3,13 @@  from functools import cache  from secrets import token_urlsafe -from bonsai import LDAPDN +try: +    from bonsai import LDAPDN + +    BONSAI_AVAILABLE = True +except ImportError: +    BONSAI_AVAILABLE = False +  from python_freeipa import ClientMeta  from arthur.config import CONFIG 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)  |