Skip to content

Commit

Permalink
fix: prevent postgres credentials leak (#3895)
Browse files Browse the repository at this point in the history
Co-authored-by: Kuchenpirat <[email protected]>
  • Loading branch information
hay-kot and Kuchenpirat authored Jul 25, 2024
1 parent 29b4a3c commit edf649d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions mealie/core/settings/db_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,18 @@ def db_url(self) -> str:

@property
def db_url_public(self) -> str:
user = self.POSTGRES_USER
password = self.POSTGRES_PASSWORD
return self.db_url.replace(user, "*****", 1).replace(password, "*****", 1)
if self.POSTGRES_URL_OVERRIDE:
return "Postgres Url Overridden"

return str(
PostgresDsn.build(
scheme="postgresql",
username="******",
password="******",
host=f"{self.POSTGRES_SERVER}:{self.POSTGRES_PORT}",
path=f"{self.POSTGRES_DB or ''}",
)
)


def db_provider_factory(provider_name: str, data_dir: Path, env_file: Path, env_encoding="utf-8") -> AbstractDBProvider:
Expand Down

0 comments on commit edf649d

Please sign in to comment.