Files
Comparison_Project/app/config.py

46 lines
1.8 KiB
Python
Raw Permalink Normal View History

import os
2026-08-06 18:17:33 +05:30
# project base url
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
class Config:
# secret key
SECRET_KEY = os.getenv("SECRET_KEY", "dev-secret-key")
# Database variables
DB_DIALECT = os.getenv("DB_DIALECT")
DB_DRIVER = os.getenv("DB_DRIVER")
DB_USER = os.getenv("DB_USER")
DB_PASSWORD = os.getenv("DB_PASSWORD")
DB_HOST = os.getenv("DB_HOST")
DB_PORT = os.getenv("DB_PORT")
DB_NAME = os.getenv("DB_NAME")
# database connection url
SQLALCHEMY_DATABASE_URI = (
f"{DB_DIALECT}+{DB_DRIVER}://"
f"{DB_USER}:{DB_PASSWORD}@"
f"{DB_HOST}:{DB_PORT}/"
f"{DB_NAME}"
)
SQLALCHEMY_TRACK_MODIFICATIONS = False
2026-08-06 18:17:33 +05:30
# uploads folder path
UPLOAD_FOLDER = os.path.join(BASE_DIR, "static", "uploads")
# file extension
ALLOWED_EXTENSIONS = {"xlsx", "xls", "csv"}
2026-08-06 12:20:50 +05:30
2026-08-06 18:17:33 +05:30
# ---------------- 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})")