By default in CI4 we put the database connection values like hostname, username and password directly inside the Database.php
Example:
$default = [
'DSN' => '',
'hostname' => 'localhost',
'username' => 'adm',
'password' => 'password',
'database' => 'mydatabase',
'DBDriver' => 'sqlsrv',
'DBPrefix' => '',
'pConnect' => false,
'DBDebug' => false,
'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port' => 3306,
];
These values are kind of sensitive and attackers might able to obtain it if they somehow get the source code.
I try to declare a variable which value is passed in from other place and set it for the database connection value, but it seems like the configuration just allow string type.
So is there a way that we can get rid of using the hard-coded values inside this configuration? Or using any encryption method here?