Coverage for app/config.py: 100.00%

26 statements  

« prev     ^ index     » next       coverage.py v7.14.1, created at 2026-07-25 15:51 +0000

1 

2from pydantic_settings import BaseSettings 

3 

4 

5class Settings(BaseSettings): 

6 # Database 

7 DATABASE_URL: str 

8 

9 # Celery (optional - only needed for API runtime, not for migrations) 

10 CELERY_BROKER_URL: str = "amqp://admin:admin@rabbitmq:5672/" 

11 CELERY_RESULT_BACKEND: str = "redis://redis:6379/0" 

12 

13 # Git 

14 TEMP_REPO_BASE_PATH: str = "/tmp/worker_repos" 

15 GIT_ACCESS_TOKEN: str = "" # Token for HTTPS git authentication 

16 

17 # Keycloak — single source of truth for authentication 

18 KEYCLOAK_SERVER_URL: str = "http://keycloak:8080" 

19 KEYCLOAK_REALM: str = "dhbw" 

20 KEYCLOAK_CLIENT_ID: str = "appstore-backend" 

21 KEYCLOAK_CLIENT_SECRET: str = "" # Set via environment variable 

22 

23 # CORS 

24 CORS_ORIGINS: list[str] = ["http://localhost:3000", "http://localhost:5173"] 

25 

26 # Symmetric Fernet key shared with the worker. Used to encrypt OpenStack 

27 # credentials at rest and to seal the envelope shipped through Celery. 

28 # Generate: python -c 'from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())' 

29 CREDENTIAL_ENCRYPTION_KEY: str 

30 

31 # SMTP (Gmail). Required for the post-deploy notification mails. 

32 # Use a Google "App password" (the regular password won't work with 

33 # 2FA enabled). 

34 # 

35 # SMTP_ENABLED is the explicit kill-switch — set it to False to turn 

36 # mail delivery into a no-op even when credentials are populated. It 

37 # lives separately from the credentials so operators can keep the 

38 # app-password in .env while disabling mail in dev/CI, and so the 

39 # resend-access endpoint can distinguish "we chose not to send" 

40 # (HTTP 503) from "SMTP refused" (HTTP 502). 

41 SMTP_ENABLED: bool = False 

42 SMTP_HOST: str = "smtp.gmail.com" 

43 SMTP_PORT: int = 587 

44 SMTP_USER: str = "" 

45 SMTP_PASSWORD: str = "" 

46 SMTP_FROM_EMAIL: str = "" 

47 SMTP_FROM_NAME: str = "Click-n-Deploy" 

48 

49 # Public URL the deployment detail page is reachable under, used in 

50 # the owner-summary mail to deep-link back into the UI. No trailing 

51 # slash. Falls back to the first CORS origin in dev. 

52 APP_BASE_URL: str = "http://localhost:5173" 

53 

54 class Config: 

55 env_file = ".env" 

56 case_sensitive = True 

57 extra = "ignore" 

58 

59 

60settings = Settings()