8305352497
- ldap_auth Service: User bindet als user@domain (kein Servicekonto noetig), Gruppenpruefung ueber Matching-Rule-In-Chain (verschachtelte Gruppen) - Login-Route: lokaler User zuerst, dann LDAP-Fallback; LDAP-User werden lokal gespiegelt (is_ldap, is_admin, Profildaten aus AD) - Neue Config: ldap_domain, ldap_admin_group, ldap_timeout_seconds - ldap3 Dependency, 7 Unit-Tests (ldap3 gemockt), ruff+mypy sauber - Gruppen-DN verified am DC: CN=Domänen-Admins,CN=Users,DC=insight,DC=local
62 lines
1.9 KiB
Python
62 lines
1.9 KiB
Python
"""Application configuration via pydantic-settings.
|
|
|
|
All values are read from environment variables / .env file.
|
|
See .env.example for the full list.
|
|
"""
|
|
|
|
from functools import lru_cache
|
|
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""Central application settings."""
|
|
|
|
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore")
|
|
|
|
# Core
|
|
app_env: str = "development"
|
|
app_name: str = "Insight Updater"
|
|
secret_key: str = "dev-secret-change-me-32-chars-min"
|
|
log_level: str = "INFO"
|
|
log_format: str = "json"
|
|
|
|
# JWT
|
|
jwt_algorithm: str = "RS256"
|
|
jwt_private_key_path: str = "keys/private.pem"
|
|
jwt_public_key_path: str = "keys/public.pem"
|
|
jwt_access_token_expire_minutes: int = 30
|
|
jwt_refresh_token_expire_days: int = 7
|
|
|
|
# Database
|
|
database_url: str = "sqlite+aiosqlite:///./data/app.db"
|
|
|
|
# Jobs: a claimed/running job without satellite reports for this many
|
|
# seconds is considered stale and marked failed by the janitor
|
|
job_stale_timeout: int = 3600
|
|
|
|
# LDAP / Active Directory (user bind, no service account)
|
|
ldap_enabled: bool = False
|
|
ldap_uri: str = ""
|
|
ldap_domain: str = "" # bind as user@domain; empty = plain username bind
|
|
ldap_user_search_base: str = ""
|
|
ldap_user_filter: str = "(sAMAccountName={username})"
|
|
ldap_admin_group: str = "" # DN, e.g. CN=Admins,CN=Users,DC=example,DC=com
|
|
ldap_timeout_seconds: int = 10
|
|
|
|
# CORS
|
|
cors_origins: str = "http://localhost:3000,http://localhost:8000"
|
|
|
|
@property
|
|
def cors_origin_list(self) -> list[str]:
|
|
return [o.strip() for o in self.cors_origins.split(",") if o.strip()]
|
|
|
|
@property
|
|
def is_production(self) -> bool:
|
|
return self.app_env.lower() == "production"
|
|
|
|
|
|
@lru_cache
|
|
def get_settings() -> Settings:
|
|
return Settings()
|