Add LDAP Aunthentication

This commit is contained in:
2026-08-06 18:17:33 +05:30
parent e7805b71a8
commit b380ed510b
11 changed files with 169 additions and 225 deletions

View File

@@ -1,4 +1,6 @@
import os
# project base url
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
class Config:
# secret key
@@ -21,14 +23,23 @@ class Config:
)
SQLALCHEMY_TRACK_MODIFICATIONS = False
# uploads folder path
UPLOAD_FOLDER = os.path.join(BASE_DIR, "static", "uploads")
# file extension
ALLOWED_EXTENSIONS = {"xlsx", "xls", "csv"}
# LDAP Configuration New
LDAP_SERVER = os.getenv("LDAP_SERVER")
LDAP_PORT = int(os.getenv("LDAP_PORT", 389))
LDAP_USE_SSL = os.getenv("LDAP_USE_SSL", "False").lower() == "true"
LDAP_BASE_DN = os.getenv("LDAP_BASE_DN")
LDAP_DOMAIN = os.getenv("LDAP_DOMAIN")
LDAP_SEARCH_BASE = os.getenv("LDAP_SEARCH_BASE")
# ---------------- LDAP settings ----------------
USE_LDAP_AUTH = os.getenv("USE_LDAP_AUTH", "false").lower() == "true"
# e.g. "ldap://192.168.0.25:389" or "ldaps://192.168.0.25:636" (preferred, encrypted)
LDAP_SERVER = os.getenv("LDAP_URL", "ldap://192.168.0.25:389")
# Service/admin account used only to SEARCH for a user's real DN.
# The user's own password is never used for this bind.
LDAP_BIND_DN = os.getenv("LDAP_BIND_DN", "cn=admin,dc=lcepl,dc=org")
LDAP_BIND_PASSWORD = os.getenv("LDAP_BIND_PASSWORD", "")
# Base DN to search for user entries under
LDAP_BASE_DN = os.getenv("LDAP_BASE_DN", "dc=lcepl,dc=org")
# Used only as a fallback to build an email if the directory entry has none
LDAP_DOMAIN = os.getenv("LDAP_DOMAIN", "lcepl.org")
# Filter used to find the user's entry by their login username.
# Standard OpenLDAP attribute is "uid". Active Directory would use sAMAccountName.
LDAP_SEARCH_FILTER = os.getenv("LDAP_SEARCH_FILTER", "(uid={username})")