diff --git a/mealie/app.py b/mealie/app.py index 112c3f0f3af1..b40184e45225 100644 --- a/mealie/app.py +++ b/mealie/app.py @@ -63,7 +63,20 @@ def system_startup(): start_scheduler() logger.info("-----SYSTEM STARTUP----- \n") logger.info("------APP SETTINGS------") - logger.info(settings.json(indent=4, exclude={"SECRET", "DEFAULT_PASSWORD", "SFTP_PASSWORD", "SFTP_USERNAME"})) + logger.info( + settings.json( + indent=4, + exclude={ + "SECRET", + "DEFAULT_PASSWORD", + "SFTP_PASSWORD", + "SFTP_USERNAME", + "DB_URL", # replace by DB_URL_PUBLIC for logs + "POSTGRES_USER", + "POSTGRES_PASSWORD", + }, + ) + ) create_general_event("Application Startup", f"Mealie API started on port {settings.API_PORT}") diff --git a/mealie/core/config.py b/mealie/core/config.py index b1f59a09ee7a..6de1f56b48f2 100644 --- a/mealie/core/config.py +++ b/mealie/core/config.py @@ -133,6 +133,20 @@ class AppSettings(BaseSettings): ) return determine_sqlite_path() + DB_URL_PUBLIC: str = "" # hide credentials to show on logs/frontend + + @validator("DB_URL_PUBLIC", pre=True) + def public_db_url(cls, v: Optional[str], values: dict[str, Any]) -> str: + url = values.get("DB_URL") + engine = values.get("DB_ENGINE", "sqlite") + if engine == "postgres": + user = values.get("POSTGRES_USER") + password = values.get("POSTGRES_PASSWORD") + return url.replace(user, "*****", 1).replace(password, "*****", 1) + else: + # sqlite + return url + DEFAULT_GROUP: str = "Home" DEFAULT_EMAIL: str = "changeme@email.com" DEFAULT_PASSWORD: str = "MyPassword" diff --git a/mealie/routes/debug_routes.py b/mealie/routes/debug_routes.py index a1fa7ec9bfe5..88c83b637240 100644 --- a/mealie/routes/debug_routes.py +++ b/mealie/routes/debug_routes.py @@ -25,7 +25,7 @@ async def get_debug_info(): api_port=settings.API_PORT, api_docs=settings.API_DOCS, db_type=settings.DB_ENGINE, - db_url=settings.DB_URL, + db_url=settings.DB_URL_PUBLIC, default_group=settings.DEFAULT_GROUP, )