From 2298bfbd7e2373678e71eb03e8fea232c354573b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B4mulo=20Mendes=20Figueiredo?= Date: Tue, 25 Feb 2025 13:07:53 -0300 Subject: [PATCH] refac: conditional import of ldap3 --- backend/open_webui/routers/auths.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/routers/auths.py b/backend/open_webui/routers/auths.py index 3fa2ffe2e..1543fb400 100644 --- a/backend/open_webui/routers/auths.py +++ b/backend/open_webui/routers/auths.py @@ -34,6 +34,7 @@ from fastapi.responses import RedirectResponse, Response from open_webui.config import ( OPENID_PROVIDER_URL, ENABLE_OAUTH_SIGNUP, + ENABLE_LDAP ) from pydantic import BaseModel from open_webui.utils.misc import parse_duration, validate_email_format @@ -51,8 +52,10 @@ from open_webui.utils.access_control import get_permissions from typing import Optional, List from ssl import CERT_REQUIRED, PROTOCOL_TLS -from ldap3 import Server, Connection, NONE, Tls -from ldap3.utils.conv import escape_filter_chars + +if ENABLE_LDAP.value: + from ldap3 import Server, Connection, NONE, Tls + from ldap3.utils.conv import escape_filter_chars router = APIRouter()