feat: add auth config fields (SECRET_KEY, LDAP_*)

This commit is contained in:
Oliver Hofmann 2026-04-27 09:30:21 +02:00
parent 8d7f9df6fc
commit 60c21b46de
4 changed files with 26 additions and 3 deletions

View File

@ -1,8 +1,11 @@
APP_ENV=development
APP_PREFIX=
DATABASE_URL=sqlite:///./app.db
SECRET_KEY=changeme-replace-in-production
# Produktion (MariaDB):
# Produktion (MariaDB + LDAP):
# APP_ENV=production
# APP_PREFIX=/uph
# DATABASE_URL=mysql+pymysql://user:password@db:3306/efihub
# DATABASE_URL=mysql+pymysql://user:password@db:3306/efihub
# SECRET_KEY=<python -c "import secrets; print(secrets.token_hex(32))">
# LDAP_ENABLED=true

View File

@ -9,6 +9,11 @@ class Settings(BaseSettings):
APP_ENV: str = "development"
APP_PREFIX: str = ""
DATABASE_URL: str = "sqlite:///./app.db"
SECRET_KEY: str = "changeme-replace-in-production"
LDAP_ENABLED: bool = False
LDAP_SERVER: str = "gso1.ads1.fh-nuernberg.de"
LDAP_DOMAIN: str = "ADS1"
LDAP_SEARCH_BASE: str = "OU=users,OU=EFI,OU=Faculties,DC=ADS1,DC=fh-nuernberg,DC=de"
@lru_cache

View File

@ -4,4 +4,9 @@ pydantic-settings
sqlalchemy
jinja2
pytest
httpx
httpx
alembic
python-jose[cryptography]
passlib[bcrypt]
python-multipart
ldap3

10
tests/test_config.py Normal file
View File

@ -0,0 +1,10 @@
from app.core.config import get_settings
def test_new_config_fields_have_defaults():
s = get_settings()
assert hasattr(s, "SECRET_KEY")
assert hasattr(s, "LDAP_ENABLED")
assert s.LDAP_ENABLED is False
assert s.LDAP_SERVER == "gso1.ads1.fh-nuernberg.de"
assert s.LDAP_DOMAIN == "ADS1"