Build [v.1.3.6]

This commit is contained in:
Daniel Bedeleanu
2026-04-11 17:14:22 +03:00
parent 775808506f
commit 704934165f
27 changed files with 738 additions and 685 deletions

View File

@@ -5,6 +5,7 @@ from typing import List
from passlib.context import CryptContext
import ldap3
from ldap3.utils.conv import escape_filter_chars
from ldap3.utils.dn import escape_rdn
import json
import os
from .. import models, schemas, database, auth
@@ -32,7 +33,8 @@ def authenticate_ldap(username, password):
try:
server = ldap3.Server(config["server_uri"], use_ssl=config.get("use_tls", False), get_info=ldap3.ALL)
log.debug(f"LDAP: Server object created: {config['server_uri']}")
user_dn = config["user_template"].format(username=username)
safe_username_rdn = escape_rdn(username)
user_dn = config["user_template"].format(username=safe_username_rdn)
log.debug(f"LDAP: Attempting bind for DN: {user_dn}")
conn = ldap3.Connection(server, user=user_dn, password=password, auto_bind=True)