Prevent unauthorized access to system resources using default credentials.
config :my_app, MyApp.Repo,
database: "my_app_prod",
username: "postgres",
password: "postgres",
hostname: "localhost"
This is the configuration for a PostgreSQL database in an Elixir application. The username and password are set to 'postgres', which are commonly used default credentials. If an attacker knows or guesses that the application is using these default credentials, they can gain unauthorized access to the database.
config :my_app, MyApp.Repo,
database: "my_app_prod",
username: System.get_env("DB_USERNAME"),
password: System.get_env("DB_PASSWORD"),
hostname: "localhost"
In the secure example, the username and password are not hard-coded into the application. Instead, the application retrieves them from environment variables. This helps to keep the credentials secure.